在重新设置两个串联的分支后,我遇到了这个“git diff diff”问题。相同的提交被应用于相同的分叉点,所以我很困惑地看到分支分歧。甚至补丁 ID 也是一样的。
查看原始差异发现差异在于“提交者时间”:
$ diff <(git show --format=raw $COMMIT1) \
<(git show --format=raw $COMMIT2)
1c1
< commit $COMMIT1
---
> commit $COMMIT2
5c5
< committer $ME <me@work.com> 1470128045 +0200
---
> committer $ME <me@work.com> 1470129095 +0200
在 git rebase 上重做--committer-date-is-author-date
rebase 修复了一些分歧,但不是全部。(我不确定为什么..?我认为分歧发生在第一次重新合并时)
然后我使用 filter-branch 作为大锤:
git filter-branch --env-filter \
'export GIT_COMMITTER_DATE=$GIT_AUTHOR_DATE'\
origin/master..HEAD
这足以使系列保持一致:
$ git show --format=raw HEAD | egrep 'author|committer'
author $ME <me@work.com> 1470065063 +0200
committer $ME <me@work.com> 1470065063 +0200