Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I re-merge commits that were reverted in github?

I will try my best to concisely describe my current situation, and would be most grateful for some advice.

I merged in a big feature branch of code this morning that turned out to have a critical error. In order to undo it, my coworker reverted the merge (which had several commits) in GitHub and after pulling, all appeared to be well.

After making some tweaks to the feature branch, I wanted to make sure it could go in again, so I used 'git merge master' on my feature branch (like I always do) to make sure everything is up to date.

Surprisingly, the result of that was to delete all of the new code that I am needing to merge back in to the master repo!

Is this due to the revert that occurred on the branch? Looking through the git log, I can see that all of the commits are there still. And even more strange, the pull request in github doesn't show any of the original commits in the diff, only what I have changed since the revert.

Can someone help me make sense of this?

I know some people have suggested simply reverting the revert, but I need to go back in clean, as the changes I made deal with the structure of much of the code.

like image 987
Lizza Avatar asked May 20 '15 03:05

Lizza


1 Answers

I ran into this very same issue once. My solution that worked was to "revert the revert" before merging master back into my branch.

What that does is leave you with all your changes, including the new fixes that you've got.

git checkout master
git checkout -b master-with-revert-revered
git revert <revert commit id>
git checkout fixed-branch
git merge master-with-revert-revered

After that, your fixed-branch should be directly mergable back into master with no problem.

like image 130
Daniel Avatar answered Oct 01 '22 14:10

Daniel