在使用一個工具來確定先前匯出的給定提交的相關歷史記錄時,我在 git log 中發現了一個相當奇怪的行為,我似乎無法確定正在發生的事情。我希望有人可以幫助解釋這種行為。
我創建了以下提交圖,并且在同一個存盤庫中有兩個單獨的作業區。作業區 A 在列出的每個提交中都有一個檔案更新,除了簡單合并的 E 和 I(例如git merge bar創建的提交 I)。另一方面,作業區 B 僅在提交 A 和 L 中更改了檔案。
當我運行時git log --name-only --oneline -- workspaceA,我列出了提交“我”,但沒有檔案受到影響:
b7faf96 (HEAD -\> main) Commit I
a3c265e Commit H
workspaceA/H
e03be40 (bar) Commit L
workspaceA/L
7ead348 Commit G
workspaceA/G
7b80d8d (tag: workspaceA-2020.0.2.0, baz) Commit B
workspaceA/B
d383bfa Commit F
workspaceA/F
6d2b8a4 (tag: workspaceB-2020.0.1.0, tag: workspaceA-2020.0.1.0) Commit A
workspaceA/A
...
請注意,此串列包含 Commit 'I' 但它沒有在提交下列出的檔案。
Now, when I run git log --name-only --oneline -- workspaceB I get a list that doesn't contain commit 'I' at all:
e03be40 (bar) Commit L
workspaceB/L
6d2b8a4 (tag: workspaceB-2020.0.1.0, tag: workspaceA-2020.0.1.0) Commit A
workspaceB/A
...
My problem is that there isn't any consistency in whether commit 'I' shows up, even though none of the files were actually changed during the merge which created commit 'I'. Can anyone explain why this is happening?
This doesn't meet my expectations because I can't see why commit 'I' only shows up when filtering for one folder and not the other, even though the merge involves changes to both folders as seen in my screenshot.
uj5u.com熱心網友回復:
發生這種情況的原因是因為 Git從您指定的路徑過濾器的角度向您顯示代表新狀態的提交串列。
從 POV 來看,合并兩邊的workspaceA那個檔案夾里的東西都有變化。提交有兩個父母:和. 的and是 commit ,并且在and之間以及and之間至少有一個變化。這意味著即使提交本身不包含任何更改,提交也會有新的狀態。IHLmerge-baseHLBworkspaceABHBLIworkspaceA
請注意,情況并非如此workspaceB。B和之間沒有變化, 和 之間有H變化。因此,與已經列出的 相比,合并提交不會有狀態更改。BLIL
uj5u.com熱心網友回復:
默認情況下,git log完全隱藏合并提交的差異。
添加diff-merges選項之一以查看考慮了哪些檔案:我建議--cc,您也可以嘗試-c或-m.
從git 幫助日志:
差異格式:
[...]
--diff-merges=(off|none|on|first-parent|1|separate|m|combined|c|dense-combined|cc)指定用于合并提交的差異格式。默認是
off除非--first-parent正在使用,在這種情況下first-parent是默認值。
選項的簡寫是:
-m對于--diff-merges=on或--diff-merges=m-c為了combined--cc為了dense-combined
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/449510.html
標籤:git
上一篇:使用git中某個特定分支的腳本
