What are the pros-cons of using git worktrees vs maintaining multiple clones with --reference
flag? The main scenario I am considering is when a developer needs to maintain multiple git repositories on the disk for old releases (release/1.0, release/2.0, release/3.0) because switching branches on a single git repo and rebuilding would be costly.
Using worktrees the developer could have a single clone of the repo, and any old releases could be created as worktrees of the repo using cd /opt/main/
, git worktree add /opt/old_release_1 release/1.0
. Using reference clones, the developer maintains a main clone somewhere, and uses cd /opt/old_release_1
, git clone --reference /opt/main/.git ssh://git@github.com/myrepo.git
to create clone repositories for the old releases.
It seems like they can both accomplish the same goal. Are there benefits to one over the other in terms of speed, disk space... other things?