2013-11-20 14 views
1
  f1---f2     - short term branch "feature1" 
     /  \ 
     h--h--h---h--h1--h2-   - long term branch "hofix" 
    /  \ \  \ 
    /  \ \  \ 
    m----m------m---m------m--  - long term branch "master" 
        |  | 
       1e1e1e 2f2f2f 

我合併2個提交差異的分支(15個文件改變totaly)。 奔着:Git diff工作不正確 - 對很多更改

$ git show --pretty="format:" --name-only 1e1e1e..2f2f2f 

我收到超過42 000文件從我的項目改變。爲什麼?

預計:我將展示與F1,F2,H1,H2承諾

附:DIFF可能是因爲「合併分支」起源/ 0411-hotfix'「提交?

+0

'git merge-base 1e1e1e 2f2f2f'返回什麼?哪個「h」? – VonC

+0

這很少發生,從1起5起。 我無法抓住它。 – maxgu

回答

4

1e1e1e..2f2f2f表示:

  • 是可達的距離2f2f2f
  • 排除那些到達從1e1e1e

所有提交(請參閱 「SPECIFYING RANGE」 從gitrevisions

如果這些SHA1引用合併的兩個提交,您有:

1e1e1e 
     | 
x--x--x 
     \ 
     Z 
    /
y--y--y 
     | 
    2f2f2f 

這將使你的所有「y」提交的所有文件,這可能走得太遠,因爲最先提交,這意味着你得到的所有文件。

然而,由於git diff採取一系列的提交(而不是git show),你可以嘗試,如 「How to 「git show」 a merge commit with combined diff output」:

git diff --name-only 1e1e1e..2f2f2f 

或者乾脆使用合併SHA1「Z ',如在「List all modified files in git merge commit - even the fast forwarded」中:

git log -m -1 --name-only --pretty="format:" <Merge SHA>