Git equivalent to 'hg share'?

Is there a way to share repository history in git without cloning the entire folder again? Something equivalent to Mercurial's

hg share project project-branch 

https://www.mercurial-scm.org/wiki/ShareExtension

+6
source share
2 answers

If I understand the documentation for hg share , the closest equivalent to Git will be git worktree , a new feature in version 2.5:

Manage multiple work trees attached to the same repository.

A Git repository can support multiple working trees, allowing you to check multiple branches at a time. With git worktree add , a new work tree is associated with the repository. This new working tree is called a "linked working tree", not a "main working tree" prepared by "git init" or "git clone". The repository has one main working tree (if it is not a bare repository) and zero or more related working trees.

I believe this is still in beta and there is an explicit warning not to use it with submodules.

Running git worktree add ../some/path/ branch from the repository creates a new working copy with branch in ../some/path/ .

A more detailed overview of this new team can be found on the GitHub blog .

+5
source

It was too long to comment, so the new answer:

I consider this thread to be completely normal in hg - while in git this is not possible, neither with the working tree, nor with any other command, as it seems (?)

 3 bash-4.2# cd m/ 3 bash-4.2# hg init 3 bash-4.2# cd .. 3 bash-4.2# hg share m pm1 updating working directory 0 files updated, 0 files merged, 0 files removed, 0 files unresolved 3 bash-4.2# hg share m pm2 updating working directory 0 files updated, 0 files merged, 0 files removed, 0 files unresolved 3 bash-4.2# cd pm1/ 3 bash-4.2# touch foo 3 bash-4.2# hg add foo 3 bash-4.2# hg commit -m test foo 3 bash-4.2# cd ../pm2/ 3 bash-4.2# hg log changeset: 0:d5e4a426dca0 tag: tip user: xxx date: Wed Apr 10 15:32:32 2019 +0200 summary: test 3 bash-4.2# ls 3 bash-4.2# hg summary parent: -1:000000000000 (no revision checked out) branch: default commit: (clean) update: 1 new changesets (update) # <--------------- ! :-) 3 bash-4.2# hg up 1 files updated, 0 files merged, 0 files removed, 0 files unresolved 3 bash-4.2# ls foo 

In git, they do not support this thread. This allows the same only to be checked ONCE - and their excuse (unclean working trees) does not really convince me, since in hg this is also possible, as you can see.

Also in hg, to update the general one, you, well, update it (hg pull).

In Git, you should say:

 git fetch origin +refs/heads/*:refs/heads/* --prune 
0
source

Source: https://habr.com/ru/post/1235305/


All Articles