2011-12-28 72 views
0

鑑於有描述如下樹:如何獲取版本樹中兩次提交之間的所有提交?

 d1a--d1b---d1c--d1d--d1e  <dev> 
    /   / \ 
a--b--c---d---e--------f---g----h--i <master> 

a是最古老的承諾,而i是最新的一個,該HEAD d1a分支出來到一個新的分支開發,添加了一些新的更改和(從fd1d)合併的更改,然後最終合併回h'主'。

在做git的日誌/轉列表,我該如何選擇:

  1. 從頭部所有提交到E: I,H,G,F,E,D1E,D1D
  2. 所有提交從頭部到G: I,H,G
  3. 所有從HEAD提交到D1B: I,H,G,F,D1E,D1D,D1C,D1B

許多提前任何指針感謝/建議/提示!

回答

-1

man git-rev-parse

SPECIFYING RANGES 
    History traversing commands such as git log operate on a set of commits, not just a single commit. To these 
    commands, specifying a single revision with the notation described in the previous section means the set of commits 
    reachable from that commit, following the commit ancestry chain. 

    To exclude commits reachable from a commit, a prefix^notation is used. E.g. ^r1 r2 means commits reachable from r2 
    but exclude the ones reachable from r1. 

    This set operation appears so often that there is a shorthand for it. When you have two commits r1 and r2 (named 
    according to the syntax explained in SPECIFYING REVISIONS above), you can ask for commits that are reachable from r2 
    excluding those that are reachable from r1 by ^r1 r2 and it can be written as r1..r2. 

    A similar notation r1...r2 is called symmetric difference of r1 and r2 and is defined as r1 r2 --not $(git 
    merge-base --all r1 r2). It is the set of commits that are reachable from either one of r1 or r2 but not from both. 

    Two other shorthands for naming a set that is formed by a commit and its parent commits exist. The r1^@ notation 
    means all parents of r1. r1^! includes commit r1 but excludes all of its parents. 

甚至還有一個例子,所以我RTFM ;-)

+0

THX的答覆! 但是,我做了RTFM ...並沒有像預期的那樣工作。 我做了:git log .. 但是得到了i,h,g,f,d1e,d1d,d1c,d1b,d1a ... ,顯然這不是我想要的。 有什麼想法? – Justin 2011-12-28 09:17:18

+0

嘗試添加'--ancestry-path'(來自git log聯機幫助頁) – Reactormonk 2011-12-28 12:13:52

+0

好吧,我也試過,--ancestry-path會給出類似於i,h,g,f的內容,跳過其他路徑上的提交。 – Justin 2011-12-28 12:28:15