How to load only the necessary parts of a remote project in Git?

If you work in a large remote repository and want to limit the download to several branches that you work on, how do you configure the git-clone command, assuming that in this case this is the correct command

+3
source share
2 answers

If you work with two branches in two separate directories, you can configure one of them as a clone of the other:

git clone http://remote/repo.git branch-a
git clone branch-a branch-b

Then attach the remote control originto branch-b:

cd branch-b
git remote add origin http://remote/repo.git

( origin). , , .

, 1 , .

+1

git , git . - du , , , . , - , . , , hardlinks, -... .

, , , ? script git contrib git-new-workdir ( git.git), , .git - , HEAD. script - , git:

git new-workdir <original-repo> <new-workdir-path>

Voila! .git, , , . , !

, , - . , - , . !

, , . . , ( ! , !) .

. - , . git log branchA..branchB. - , . ? 1000 ? ? . .

- ? , , , git-clone refspec ( --mirror, , ). , , , , :

mkdir foo && cd foo && git init
git remote add origin <url>
# set up a refspec to get the branch(es) you want
git config remote.origin.fetch "+refs/heads/foo:refs/remotes/origin/foo ..."
git fetch origin

- , master, .

, , , . , , . , , , (.. ), .

+3

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


All Articles