We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
To move a subdirectory of a git repository into a new repo, conserving as much history as possible (keeping related commits), we'll use git subtree.
git subtree
First, open up a terminal and browse to the source repo:
cd literate-unitb
Let's say the directory we want to move to a new repo is libs/invariants.
libs/invariants
We tell git to create a new branch (e.g. called amin/separate-invariants) from the split subtree, that will contain only the subdir we specify:
amin/separate-invariants
git subtree split -P libs/invariants -b amin/separate-invariants
Now, we go outside the current repo, make a new folder an initialize a new git repo:
cd .. mkdir invariants cd invariants git init
And finally, we pull the new branch from the source repo into the new repo's master:
git pull ../literate-unitb amin/separate-invariants
That's it!