为什么git rebase --onto ab,git rebase --onto ba创建了与原始版本不同的SHA1?

jon*_*rry 4 git

假设您有以下修订图,c为当前分支:

c   a
 \ /
  b
Run Code Online (Sandbox Code Playgroud)

git rebase --onto a b 创建以下内容:

    c
   /
  a
 /
b
Run Code Online (Sandbox Code Playgroud)

并且git rebase --onto b a返回到图:

c   a
 \ /
  b
Run Code Online (Sandbox Code Playgroud)

但是,在两次重组之前,c的新SHA1与c的旧SHA1不同.为什么会这样?

Cas*_*bel 7

提交的SHA1取决于提交的所有内容,包括元数据.特别是,它取决于提交时间戳.你的两次重定位提交有一个新的时间戳,所以它有一个新的SHA1.

(请注意,最初编写时有"作者日期",并且在记录实际提交时有"提交者日期".只有后者发生了变化.要自己查看,请使用git log --pretty=fuller,或者只是查看提交in gitk.)