git rebase -i — why is it changing commit hashes?

前端 未结 5 1039
情书的邮戳
情书的邮戳 2021-02-05 17:09

So I\'m more or less familiar with how rebasing works, but up until recently I usually just did a git rebase -i HEAD~20, and modified whatever needed to be modified

5条回答
  •  别那么骄傲
    2021-02-05 17:55

    this is because when you rebase the node in HEAD that's 20 commits prior to the current one interactively, you are starting at the node in HEAD 20 commits ago and reapplying the subsequent 20 commits as if they're new, with the option to make changes. Even if you only change (squash) commit -20 and -19, you are still reapplying the subsequent 18 commits as if they're new commits. You are not re-using the same node for those 18 commits, you are copying their contents but appending new ones to your rebased HEAD.

    From the git book on rebasing:

    Remember again that this is a rebasing command – every commit included in the range HEAD~3..HEAD will be rewritten, whether you change the message or not.

提交回复
热议问题