BVe*_*non 3 git rebase git-history git-history-rewrite
我知道变基会重写历史。但是事后存储库中是否留下任何记录或迹象表明发生了变基?
存储库历史记录中没有任何记录表明已发生变基。
在执行 rebase 的本地存储库中,git reflog将显示 rebase 操作:
$ git reflog
e15c93a HEAD@{2}: commit: Fix transposed apiversion/kind fields
594577c HEAD@{3}: rebase (finish): returning to refs/heads/main
594577c HEAD@{4}: rebase (pick): Ignore generated files
99e5acd HEAD@{5}: rebase (fixup): Run linters before building
3f1a5e6 HEAD@{6}: rebase (fixup): # This is a combination of 2 commits.
e572c0d HEAD@{7}: rebase (start): checkout HEAD~4
ed31f54 HEAD@{8}: commit: fixup
Run Code Online (Sandbox Code Playgroud)
如果存储库存在多个副本,您可以通过注意不同副本之间的历史记录是否不同(特别是,如果您在存储库的不同副本中看到与不同提交 ID 关联的相同提交消息)来识别变基。例如,以下是 GNU hello存储库中的最后 10 次提交:
$ git log --oneline -10 origin/master
fab5dca gnulib: remove use of deprecated module non-recursive-gnulib-prefix-hack
54660e5 maint: post-release administrivia
8ed6c0e version 2.12.1
c8a7bad doc: add NEWS for 2.12.1
9af4fc2 doc: fix grammar in hello.x (thanks, Logan!)
101ccb1 maint: post-release administrivia
6fe9c7f maint: add NEWS for 2.12
8f59815 version 2.12
113f5b4 maint: allow atexit-1 test to work when wprintf failed
66f4cdd tests: remove multibyte-1 test
Run Code Online (Sandbox Code Playgroud)
对于我在该存储库的本地签出来说,这是同样的事情,我在其中修改了其中一项提交:
$ git log --oneline -10
bee78c6 gnulib: remove use of deprecated module non-recursive-gnulib-prefix-hack
5aa89a0 maint: post-release administrivia
f8542d6 version 2.12.1
47f90b4 doc: add NEWS for 2.12.1
adc57c6 doc: fix grammar in hello.x (thanks, Logan!)
101ccb1 maint: post-release administrivia
6fe9c7f maint: add NEWS for 2.12
8f59815 version 2.12
113f5b4 maint: allow atexit-1 test to work when wprintf failed
66f4cdd tests: remove multibyte-1 test
Run Code Online (Sandbox Code Playgroud)
请注意提交 id 从提交 titlted 开始有何不同doc: fix grammar in hello.x (thanks, Logan!)。这是我修改的提交,因此之后的所有内容都有一个新的提交 ID。
最后,如果您尝试git pull从上次拉取后已重新设置基础的存储库中,您将在消息的输出中git pull看到forced update:
+ fab5dca...bee78c6 master -> origin/master (forced update)
Run Code Online (Sandbox Code Playgroud)
这表明远程历史记录与上次拉取存储库时的情况相比已被修改。