Reputation: 75
A little background:
master branch of code base
dev branch of code base
both are being worked on (I know, but I just started on this project so I'm not to blame)
at one point, dev was mistakenly merged back into master, then a few commits later all those changes were reverted (manually, it looks like)
Now, I need to merge dev back into master for real, but all the changes that were accidentally merged and then reverted are, of course, missing.
I'm not quite sure what to do here other than manually making the changes after the merge.
Any thoughts?
Upvotes: 1
Views: 144
Reputation: 13743
The wonderful thing about git is its flexibility and how hard it is to actually delete something.
Here's one way to approach it:
git checkout master
git log (make note of all commits on master that you want which were done after the incorrect merge)
git reset --hard <commit before dev was merged in in error>
git cherry-pick <id's of commits previously identified>
git merge develop (to do the desired merge)
As was mentioned in the other answer, an interactive-rebase is an option too. You can use that to drop the commit that introduced the bad merge and the commits which reverted it.
Note that you'll be rewriting history, so you're going to have to push to a shared repository with --force and let the other developers know so they can re-clone, or pull the changes into a new branch, etc. Making sure to coordinate with the team before proceeding with these changes is important.
Upvotes: 1
Reputation: 114178
I would suggest an interactive rebase. Delete the commit that reverted the changes and fix any merge conflicts.
Upvotes: 1