Skip to content

Instantly share code, notes, and snippets.

@pk
Created March 18, 2010 15:38
Show Gist options
  • Save pk/336478 to your computer and use it in GitHub Desktop.
Save pk/336478 to your computer and use it in GitHub Desktop.
Extract directory from the GIT repo to the standalone GIT repo.
#!/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!"
@Blaisorblade
Copy link

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