2013-10-31 48 views
0

我有github上的存儲庫分支我想克隆。我可以在URL https://github.com/pmyusername/myrepository克隆主存儲庫(由於數據是私有的,因此不是實際的鏈接)。但是,我無法克隆位於https://github.com/myusername/myrepository/tree/branchname的分支。克隆庫,我只是需要運行:爲什麼我可以克隆主存儲庫但不支持分支?

git clone https://github.com/myusername/myrepository 

,但如果我嘗試運行:

https://github.com/myusername/myrepository/tree/branchname 

我收到的錯誤:

fatal: repository 'https://github.com/myusername/myrepository/tree/branchname' not found 

,但我知道它的存在,因爲我正在複製並粘貼它的網址。這個問題可能與我支付保密費用有關,但我不這麼認爲。有沒有人有任何想法?

+0

如果您已經擁有整個存儲庫,爲什麼需要克隆分支? – BlackVegetable

+0

該分支比儲存庫更遠。存儲庫已過時。 – Philip7899

+1

根據定義,存儲庫包含所有分支。 'master'分支可能已經過時了,但你仍然可以簽出有問題的分支(在git fetch/pull之後)。 – BlackVegetable

回答

2

我會盡力聚集所有各種意見,以簡潔的迴應...
第1步:git clone https://github.com/myusername/myrepository
第2步:git fetch
第3步:git checkout -b desired_branch#添加產地/ desired_branch結束的命令行設置遠程跟蹤

更新:
只是做了一個快速的實驗與丹尼爾斯通的建議,它似乎工作:
i:work> git clone -b metro [email protected]:user/project.git
i:work> cd project
I:\work\project> git branch -a
* metro
remotes/origin/HEAD -> origin/master
remotes/origin/master
remotes/origin/metro

0

如果您使用像GitEx這樣的UI,那麼您可以在出現的對話框中提及要克隆的分支。這將克隆與自動簽出分支的回購。

enter image description here

相關問題