I have reverted a merge commit (feature -> develop) this way:
git revert -m 1 <merge-commit-hash>
git push origin develop
A new commit has been created Revert "Merge branch 'feature'"
Now I want to revert that revert. Should I just use the following command: git revert <revert-merge-branch-commit-hash>
?
Unfortunately, in most cases the answer is probably yes. (You should revert the revert commit.)
I say "unfortunately" because in retrospect the two reverts together add unnecessary (and possibly confusing) commits to your history. Here are two possible alternatives to this:
develop
, conditions have to be nearly perfect to even consider doing this outside of emergencies. (By nearly perfect I mean: no new commits on the branch, very little time has passed since the bad commits were added and/or it's unlikely others have branched off of it yet, etc.)git rebase --no-ff [merge-base-commit]
. This will force the rebase to rewrite the commits so they can be re-merged. I might choose this if new commits were added to that previous branch and now it is ready to be brought in again.But in general, most of the time, on a shared remote develop
, it's probably going to be revert the revert.