Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git equivalent of 'hg share'?

Tags:

git

mercurial

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

like image 837
endavid Avatar asked Nov 05 '15 15:11

endavid


1 Answers

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.

like image 200
Chris Avatar answered Nov 05 '22 22:11

Chris