Is there any way to share the history of a repository in git without having to clone the whole folder again? Something equivalent to Mercurial's
hg share project project-branch
https://www.mercurial-scm.org/wiki/ShareExtension
If I'm understanding the documentation for hg share
, the closest Git equivalent would be git worktree
, a new feature in version 2.5:
Manage multiple working trees attached to the same repository.
A git repository can support multiple working trees, allowing you to check out more than one branch at a time. With
git worktree add
a new working tree is associated with the repository. This new working tree is called a "linked working tree" as opposed to the "main working tree" prepared by "git init" or "git clone". A repository has one main working tree (if it’s not a bare repository) and zero or more linked working trees.
I believe it's still in beta, and there is an explicit warning not to use it with submodules.
Running git worktree add ../some/path/ branch
from a repository creates a new working copy with branch
checked out at ../some/path/
.
A longer overview of this new command can be found on GitHub's blog.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With