2 ms·
If you use git and clone the same (or related) repositories in multiple places on a single disk, they can share the hashed object to reduce disk space and/or ne
by ZeroGravitas 5y ago
If you use git and clone the same (or related) repositories in multiple places on a single disk, they can share the hashed object to reduce disk space and/or network usage and increase speed.
One workflow is to git clone mirror the main repo and use that as a shared read-only source of historical references when cloning a new repo. You can also hardlink or reference those objects to save disk space (though some file systems will do that transparently for you).
It feels like this could be done entirely transparently to the user, for a free speed boost but it's not quite there yet and still needs some thought and setup. Some big services use this behind the scenes though so it's presumably robust.
So worth looking into if you are spending time waiting for clones.
- b15h0p 5y agoSounds like the worktree feature in git: https://git-scm.com/docs/git-worktree https://git-scm.com/docs/git-worktree
- ZeroGravitas 5y agoKind of distinct but could solve similar problems where they overlap. Worktrees let you have different branches from the same repo checked out to the file system at the same time, without needing seperate repos. The clone --shared --reference-if-able and -dissociate options let you have multiple repos with less of a space hit. They almost certainly can be used at the same time, though I've never heard of anyone doing so. The limit of only having at most a single copy of each branch checked out, which makes sense for development purposes, made worktrees unsuitable for my use, which was mostly (ab)using git as a deployment tool.