2014-03-24 26 views
1

git-rev-parse的文檔:如何分配git父代號碼?

^例如, HEAD ^,^ V1.5.1 0

A suffix^to a revision parameter means the first parent of that 
commit object. ^<n> means the <n>th parent (i.e. <rev>^ is equivalent 
to <rev>^1). As a special rule, <rev>^0 means the commit itself and is 
used when <rev> is the object name of a tag object that refers to a 
commit object. 

據我所知,Git修訂可以有多個父母,那這個語法可以用來消除其父母被稱爲,但什麼決定哪一方是「第一父母「或」第二父母「?它僅僅基於在提交合並時檢出哪個提交?

例如,git checkout master; git merge feature會導致master爲父項1,而git checkout feature; git merge master會導致feature爲父項1?或者還有其他事情在這裏發生?

回答

3

只是基於提交合並時檢出哪個提交?

沒錯。您可以使用git showgit cat-file -p HEAD查看提交的父母。

+0

還要注意,「第一個父母」在'git rev-list'中有一個特殊的標誌(' - first-parent')。因此,Git使用「第一父」作爲分支的「主線程」:您將要素合併到主線,使它們不是第一父項,因此根據定義,第一個父項必須是「主線」。 – torek