nus-cs2113-AY2122S2 / forum

3 stars 2 forks source link

Is it possible to reverse a fast forward merge #29

Open angyongming opened 2 years ago

angyongming commented 2 years ago

After finishing up my branch-Level-5, I merged it back to my master branch but forgot to tick the box to specify that I don't want a fast forward merge. As such, Git did a fast forward merge and now I don't have a separate commit for the merge.

May I check if this fast forward merge can be somehow modified into a non-fast forward merge so that I have a merge commit to tag? And if that is impossible then can I just tag my latest commit instead?

Thanks!

okkhoy commented 2 years ago

You can't make the fast-forward merge to a non-fast-forward merge. If you tag the commit that is not a merge commit, the script will anyway mark it as a non-merge commit. To simplify the situation, I can suggest making any other change using a branch, use a non-fast-forward merge and then tag that commit instead. The longer route would be to reset hard (i.e., discard all work) at the commit before the necessary merge commit and re-do the work.