2015-04-18 30 views
4

的歷史,我有以下最近提交歷史:清單完整的提交特定文件

* cb14273 Merge 'test-branch' into 'master' 
|\ 
| * a022556 Rename 'bar' to 'baz' 
| * 6489f33 Merge 'pull-request-bar-branch' into 'test-branch' 
| |\ 
| | * fdc3e37 Added 'bar' file (pull-request-bar-branch) 
| * | 3e87596 Rename 'foo' file to 'bar' 
| * | 259c0fe Merge 'pull-request-foo-branch' into 'test-branch' 
| |\ \ 
|/// 
| * | 09e7a1b Added 'foo' file (pull-request-foo-branch) 
| | | 

它說明的baz文件是如何被創造的歷史。它開始爲foo,這是通過拉取請求添加的。然後它被重新命名爲bar。另一個拉取請求還引入了bar文件,並將其合併到現有的bar中。然後它被重新命名爲baz併合併到主分支中。

我想列出baz文件(這是上述樹中的每個提交)的完整歷史記錄,所以我可以以編程方式獲取文件的貢獻者。這裏是我的嘗試:

$ git log --oneline -- baz 
a022556 Rename 'bar' to 'baz' 

沒有得到過去的文件名,所以我需要--follow

$ git log --follow --oneline -- baz 
a022556 Rename 'bar' to 'baz' 
3e87596 Rename 'foo' file to 'bar' 
09e7a1b Added 'foo' file (pull-request-foo-branch) 

獲取過去的文件重命名,但只是跟隨父母開始foo,並且不包括更改合併到bar。特別是,提交fdc3e37丟失,其版本合併bar--all--full-history都沒有改變任何東西。

$ git log --follow --merges --oneline -- baz 

添加--merges似乎根本沒有結果。

這就是我期待(提交的順序和合並提交on't真正的問題):

$ git log [some options] -- baz 
cb14273 Merge 'test-branch' into 'master' 
a022556 Rename 'bar' to 'baz' 
6489f33 Merge 'pull-request-bar-branch' into 'test-branch' 
fdc3e37 Added 'bar' file (pull-request-bar-branch) 
3e87596 Rename 'foo' file to 'bar' 
259c0fe Merge 'pull-request-foo-branch' into 'test-branch' 
09e7a1b Added 'foo' file (pull-request-foo-branch) 

有沒有什麼辦法讓這個?

回答

1

這似乎是通過使用--simplify-merges選項來解決:

$ git log --follow --simplify-merges --oneline -- baz 
a022556 Rename 'bar' to 'baz' 
fdc3e37 Added 'bar' file (pull-request-bar-branch) 
3e87596 Rename 'foo' file to 'bar' 
09e7a1b Added 'foo' file (pull-request-foo-branch) 

這不包括合併,不過沒關係我的具體情況。

雖然手冊頁不給我任何的想法是如何工作的:

Default mode 
     Simplifies the history to the simplest history explaining the final state of the tree. 
     Simplest because it prunes some side branches if the end result is the same (i.e. merging 
     branches with the same content) 

    --full-history 
     Same as the default mode, but does not prune some history. 

    --simplify-merges 
     Additional option to --full-history to remove some needless merges from the resulting 
     history, as there are no selected commits contributing to this merge. 

我不明白爲什麼會在這裏影響的結果。

相關問題