簡體   English   中英

Git 是否留下任何證據表明在事后甚至發生過變基?

[英]Does Git leave any evidence that a rebase ever even occurred after the fact?

我知道 rebase 會重寫歷史。 但是在事后存儲庫中是否有任何記錄或跡象表明發生了變基?

存儲庫歷史記錄中沒有任何記錄表明發生了變基。

在執行 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

如果存儲庫存在多個副本,您可以通過注意不同副本之間的歷史記錄是否不同來識別變基(特別是,如果您在存儲庫的不同副本中看到與不同提交 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

對於我修改其中一個提交的存儲庫的本地簽出,這是同樣的事情:

$ 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

請注意提交 ID 的不同之處,從提交標題為doc: fix grammar in hello.x (thanks, Logan!)開始。 那是我修改的提交,所以之后的所有內容都有一個新的提交 ID。

最后,如果您嘗試從自上次拉取以來已變基的存儲庫中進行git pull ,您將在git pull的輸出中看到一條forced update消息:

 + fab5dca...bee78c6 master     -> origin/master  (forced update)

這表明遠程歷史已從您上次拉取存儲庫時的樣子進行了修改。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM