Revert changes made by merge

前端 未结 4 609
你的背包
你的背包 2020-12-28 15:06

The developer was commiting small changes to two files. But during this commit, he had a merge conflict which deleted a lot of stuff (probably didn\'t have the last up to da

4条回答
  •  暖寄归人
    2020-12-28 15:58

    git revert --mainline

    Usually:

    git revert --mainline 1 dd8cbe3e4
    

    Where:

    • dd8cbe3e4 is the bad merge commit you want to undo, and
    • --mainline tells you which of the multiple previous commits is the one to restore (remember, a merge commit has multiple parent commits and you can only keep one of them).
      • I can't find a good explanation of what the 1 means, but my guess is that 1,2,3... corresponds to a list of mappings to the commits immediately before dd8cbe3e4, sorted by ascending chronological order (oldest first - which is usually what you want to revert to).

    Source:

    http://thezencoder.com/2013/09/05/how-to-correctly-revert-a-bad-merge-in-git/

提交回复
热议问题