我有一個遠程裸倉庫,有兩個分支'master'和'testing',其中HEAD是指'測試'。 如果'master'和'testing'在同一個版本(即HEAD == testing == master)上,克隆這個存儲庫時,git檢出'master'。 只有當'testing'是一個(或多個)提交落後或提前時,git clone會檢出本地的'testing'分支。 我在Mac OS X(10.6.8)上用git 1.7.5試了一下。git clone不簽出活躍的分支
附錄: 我只是試圖用非純倉庫一樣的:
mkdir A
cd A
git init
touch a
git add a
git commit -m "init repo A with a"
git checkout -b testing
現在又回到了根目錄:
cd ..
git clone A B
cd B
git branch -v -a
* master 28f599b init A
remotes/origin/HEAD -> origin/master
remotes/origin/master 28f599b init A
remotes/origin/testing 28f599b init A
它的 '主人'!回到回購A(我們仍在分支'測試'中):
cd ../A
touch b
git add b
git commit -m "add b in branch testing"
現在'測試'是一個提前'主'。現在,讓我們一個重新克隆:
cd ..
git clone A C
cd C
git branch -a -v
* testing 23bca39 add b in branch testing
remotes/origin/HEAD -> origin/testing
remotes/origin/master 28f599b init A
remotes/origin/testing 23bca39 add b in branch testing
你可以要回A,結賬「主人」重新驗證這種怪異的行爲,並用「測試」(使所有分支具有相同頭)合併。現在將A克隆到D和D將在主服務器上檢出!
我看着'GIT中LS-remote'輸出和相信我發現根的說明中,短通過git來源閱讀現在。由於克隆傳輸協議,活動分支由'HEAD'的SHA1確定,而不是refspec,而在含糊不清的情況下缺省爲'master',如帶有共享HEAD的兩個分支。 – shelhamer