Skip to content

Instantly share code, notes, and snippets.

@namelessjon
Forked from pk/split_repo.bash
Created March 24, 2010 02:44
Show Gist options
  • Save namelessjon/341933 to your computer and use it in GitHub Desktop.
Save namelessjon/341933 to your computer and use it in GitHub Desktop.
Script to split out the subdirectory from a repository to it's own repo
#!/bin/bash
FROM=$1
TO=$2
echo "Spliting '$TO' from '$FROM'"
git clone --no-hardlinks $FROM $TO
cd $TO
git filter-branch --prune-empty --subdirectory-filter $TO HEAD -- --all
git reset --hard
git gc --aggressive
git prune
echo "DONE!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment