我有几个从远程仓库克隆的工作树。如果这些是从同一个本地存储库中克隆的,我会节省大量磁盘空间,因为克隆操作会硬链接存储库文件。
是否可以从不同的来源重新克隆以生成硬链接?
我意识到我可以更改 remotes.origin.url 但这不会删除并重新链接文件。Git 也只管理部分目录,因此删除它并以这种方式重新创建它并不容易。
我有几个从远程仓库克隆的工作树。如果这些是从同一个本地存储库中克隆的,我会节省大量磁盘空间,因为克隆操作会硬链接存储库文件。
是否可以从不同的来源重新克隆以生成硬链接?
我意识到我可以更改 remotes.origin.url 但这不会删除并重新链接文件。Git 也只管理部分目录,因此删除它并以这种方式重新创建它并不容易。
If space is a concern, you might even be interested in --shared flag from git clone. What would not even need hardlinks, so it would take even less space. From documentation:
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.
Why is deleting and recreating and issue - why not do a clone with hardlinks or shared, then copy over the files that are not managed by git cp -R -n source target
, -n for
-n, --no-clobber
do not overwrite an existing file (overrides a previous -i option)