2012-11-27 52 views
1

我有幾個從遠程repo克隆的工作樹。如果這些克隆來自同一個本地回購,我會節省大量的磁盤空間,因爲克隆操作會硬連接回購文件。如何重新鏈接git repo以從硬鏈接中受益

是否有可能從不同的來源重新克隆來生成硬鏈接?

我知道我可以更改remotes.origin.url但不會刪除並重新鏈接文件。 Git也只管理目錄的一部分,所以刪除它並以這種方式重新創建並不容易。

回答

1

如果空間是一個問題,您甚至可能會對git clone中的--shared標誌感興趣。什麼都不需要硬鏈接,所以它會佔用更少的空間。從技術文檔:

When the repository to clone is on the local machine, instead of using hard links, automatically setup .git/objects/info/alternates to share the objects with the source repository. The resulting repository starts out without any object of its own. 

爲什麼刪除並重新創建和問題 - 爲什麼不與硬鏈接克隆或共享,然後在不受混帳cp -R -n source target管理的文件複製,-n爲

-n, --no-clobber 
do not overwrite an existing file (overrides a previous -i option) 
+0

'--shared'對我來說不太合適,但我甚至沒有想過'cp -n'謝謝! – artfulrobot