DEV Community


Discussion on: git revert, merge commits, confusion

4nduril profile image
Tobias Barth • Edited

There is a nice explanation here: Look for the "Undoing merges" section further down.

If you revert a merge commit and later on you want to "re-merge" that same branch, you should revert the earlier revert commit (the commit that reverted the first merge) which effectively restores that merge. And if you have new commits in the feature branch since you merged for the first time you'll have to git merge <feature> again.

You create a merge: git merge <feature>
You revert that (creating a new commit, say, <revmerge>): git revert -m 1 <mergecommit>

Later, you revert the revert: git revert <revmerge>
And merge in any changes to after the initial merge: git merge <feature>

gabeguz profile image
Gabriel Guzman Author

Ah, this is the piece of documentation I was missing on Thursday, thanks for that!