I know there is a lot of information about undoing a merge in git, but I can't seem to find any concensus on how to do this in my specific situation.
Someone essentially merged our develop
branch in to our master
branch via a pull request in bitbucket. This just happened today, so it's the last thing that was done on the master branch (we don't have to worry about other commits on top of the merge commit).
Note: We host bitbucket ourselves, so we have an older version of bitbucket. There is no revert pull request option.
From what I've read, there is essentially two ways of handling this in git:
git reset --hard *<SHA of commit before the merge>*
- This will remove the merge commit as if it never happened.
- Everywhere I read that "it's bad practice to rewrite history" or "never do this on a publicly shared repo" but they never really explain why not to do it. This seems like it will fix the problem, and it won't become a problem 6 months from now when we actually do want to redo this merge from
develop
tomaster
- If this is the best way to do it, and we do it, what happens to the pull request in bitbucket? That pull request still exists in bitbucket, but we are removing the merge commit it created, so will that mess up bitbucket in any way?
git revert -m 1 *<SHA of the merge commit>*
- This will create a new commit that undoes the changes that were done by the merge
- This would be fine, except we do intend to merge
develop
intomaster
at a later date (the next release), and from what I've read, we would have to remember to revert our revert commit before doing this, because otherwise when we mergedevelop
intomaster
, the changes that we revert today won't be included. I really don't want to have this become a problem 6 months from now, when no one remembers this revert.
TL;DR: I'm hesitant on doing git revert
because of the issues it could cause 6 months from now when we do want to do this merge again. I'm also hesitant on doing git reset
because everyone seems to warn against doing it, and it could cause issues with the pull request on bitbucket.