2016-05-30 50 views

回答

2

如「Find the parent branch of a git branch」所示,git分支沒有「父分支」。相比於其他

一個分支可以是空的,並提前比起其他:

--x--x (branch1) 
     \ 
     o--o (branch2, branch3) 

這裏,branch3可能比branch2時被認爲是「空」,並與branch1 2時提前提交。

並且無法知道branch3是從branch2還是branch1創建的。

隨着GitHub的API,你需要compare two commits,它可以是兩個分支名稱:

GET /repos/:owner/:repo/compare/hubot:branchname...octocat:branchname 

這將使你的喜歡感興趣的領域:

"status": "behind", 
"ahead_by": 1, 
"behind_by": 2, 

但是這種情況只相對於「另一個分支」而言,沒有簡單的方法來知道「其他分支」是否是其「父」。

+0

比較返回的'total_commits'怎麼樣?同樣的問題? – Johnny

+0

@Johnny是的,同樣的問題。 – VonC