I\'m in a little trouble with git.
Here is what i did.
Let's say that your feature branch feature
and master
started off like this:
master: A -> B -> C
feature: A -> D
After merging master
into feature, this is how things looked:
master: A -> B -> C
feature: A -> D -> M # M is a merge commit
Next your reverted the merge in the feature
branch by doing a git revert
. This means that you told Git to add a new commit to undo the result of the merge. Now this is the state of the two branches:
master: A -> B -> C
feature: A -> D -> M -> R # R is a revert commit
When you try to pull master
into feature
, Git is telling you that you are already up to date, because you are! The revert commit functionally undid whatever happened during the merge, but now you have two new commits in your feature
branch.
To get back to the state you were in before you made the erroneous merge in your feature
branch, you can nuke the two merge and revert commits in feature
. Follow these steps exactly:
git checkout feature # switch to your feature branch
git reset --hard HEAD~2 # nuke the 'M' and 'R' commits
After this, you can try doing a merge with master
again and all should be fine. Of course, make sure that you do the merge properly.
Note that this option involves rewriting the history of the feature
branch, via nuking commits, and should probably not be used if the branch is shared and you have already pushed the branch with the merge commit. See the answer by @torek for other options if you fall into this category.