Created
March 18, 2010 15:38
-
-
Save pk/336478 to your computer and use it in GitHub Desktop.
Extract directory from the GIT repo to the standalone GIT repo.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
FROM=$1 | |
TO=$2 | |
echo "Spliting '$TO' from '$FROM'" | |
git clone --no-hardlinks $FROM $TO | |
cd $TO | |
git filter-branch --subdirectory-filter $TO HEAD -- --all | |
git reset --hard | |
git gc --aggressive | |
git prune | |
echo "DONE!" |
Cool it helped. I'm not author, it's based on some solution I found on the stackoverflow I think. I think I did changed the origins manually later but removing it is safer, yep.
Here's a relevant question on StackOverflow (probably the source of the above script), with additional tips and variations:
http://stackoverflow.com/questions/359424/detach-subdirectory-into-separate-git-repository
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thank you for this gist. it really made understanding how to extract a directory out of an existing repo very easy. one thing i would like to add through is that afterwards you want to issue a
git remote rm origin
since origin is still pointing to the original repo that you extracted from.