How to run git rebase interactive mode to remove duplicate commits

后端 未结 2 1274
被撕碎了的回忆
被撕碎了的回忆 2020-12-17 00:13

I made a mistake when I rebase to a recent commit. ( I forgot to git fetch --all first, then rebase), and I\'ve committed and pushed to the remote branch since.

相关标签:
2条回答
  • 2020-12-17 00:24

    Give git rebase the number of commits back in time. For 10 commit back in history:

    git rebase -i HEAD~10
    

    Then simply delete the lines for the commits you want to remove in the text editor that is shown. Saving the file and exiting will start the rebase and the lines that were removed will no longer be in the history once the rebase has completed.

    0 讨论(0)
  • 2020-12-17 00:40

    I successfully removed the duplicate commits. Here is what I did: hard reset to the branching point, pull from origin, start git rebase -i SHACODE (original branching point), pick the commits that I want to keep, git rebase to the current SHACODE.

    0 讨论(0)
提交回复
热议问题