2012-10-05 128 views
1

我希望克隆GitHub的特定存儲庫,但不提交分支,換句話說:克隆主分支,僅此而已。無需提交的克隆存儲庫

我知道我可以克隆存儲庫,然後只複製除.git文件夾以外的所有文件,但想知道這是否可行。

+0

要克隆主分支,而不克隆分支? –

回答

2

你可能要像

git clone -b master --single-branch --depth 1 elsewhere.git here 

也許

git archive --remote somewhere.git master | tar -xvf - -C /where/i/want/to/put/it 
+0

我複製你的代碼,並且只添加了github的url,但是都返回錯誤:看到那個要點:https://gist.github.com/3839860 –

+0

第一個似乎需要舊的git。嘗試不使用「 - 單分支」。至於第二個,是的,它似乎不適用於github。它可能工作,如果你使用相同的SSH訪問你用於第一次嘗試或與Github,你可以簡單地獲取https://github.com/patrickmaciel/git-essential/zipball/master –

+0

當我嘗試沒有 - 單支,作品除外,作品仍然存在。至於第二,doens't工作:git檔案--remote https://github.com/patrickmaciel/git-essential/zipball/master | tar -xvf - -C。 –