Git copy repo but only for specific folder, keeping history

By.

min read

My profile

Share this:

[code:1:0fb449f1ea]cd /git/first/clone
git subtree split –prefix=mydirectory/ –branch=mybranch2[/code:1:0fb449f1ea]

go to your new directory outside your current git directory

[code:1:0fb449f1ea]cd /git/second
git init
git pull /git/first/clone namesgen[/code:1:0fb449f1ea]

Now add to master and push to remote origin (git@github.com:joesixpack/namesgen.git)
[code:1:0fb449f1ea]git remote add origin git@github.com:joesixpack/namesgen.git
git push -u origin –all[/code:1:0fb449f1ea]

Tested with git version 2.7.4
[code:1:0fb449f1ea]git –version
git version 2.7.4[/code:1:0fb449f1ea]

Source: https://ariya.io/2014/07/extracting-parts-of-git-repository-and-keeping-the-history

Share this:

Leave a Reply

Your email address will not be published. Required fields are marked *