At work, one of our repositories is very large, and sometimes I want to have a second copy of it on my machine. Because I want to work on two separate tasks and worktrees are not an option for me on this repo for multiple reasons.

Cloning this complete repository including all the LFS files is over a 22GB download and on my shitty connection that means multiple overnight sessions (as I need to keep the bandwidth clear for my work during the day).

I had downloaded it once on my machine and git provides a way to specify a local clone as the alternative source to fetch objects from while still keeping the original remote destination.

git clone --dissociate --reference ~/Projects/tools git@github.com:VarunBarad/tools

In the above example I had the repo already cloned locally at ~/Projects/tools and I was able to use it as --reference so that git doesn't need to fetch all the objects from the actual remote git@github.com/VarunBarad/tools.

The --dissociate option is useful because without it your new clone would not clone/copy all object into its store but would rather refer to the --reference for the ones that it found from there. That means when we delete the reference directory the current clone can face missing object issues.

I originally learnt about this feature from anthonywritescode's video.