Say I have a master branch in github. I raise a PR (my feature branch is in my local machine), got merged, get ready for next release.
Then I found out we have another priority release, then we revert my PR (back to original master branch state). The priority release PR will come soon.
Now in my local machine, if I git pull from master branch (remote github) to my local feature branch, all my local branch code will be gone.
How do I keep my feature code while still keep up to date with master branch from github?
1
Recreate your feature branch so that git thinks that the branch has not been merged ever….. Suppose that the feature branch is X
and its work is 4 commits:
git checkout X~4
git cherry-pick HEAD..X
At this point you have the exact same work you had before but to git, this has not been merged (these are different commits from the original 4). If you like it, place X
over here and I would suggest to rebase:
git checkout -B X
git rebase origin/master