Skip to content

Instantly share code, notes, and snippets.

@a2
Created September 5, 2011 23:08
Show Gist options
  • Save a2/1196131 to your computer and use it in GitHub Desktop.
Save a2/1196131 to your computer and use it in GitHub Desktop.
Clones a subfolder into a new git repository.
git clone --no-hardlinks OLD_FLDR NEW_FLDR
cd NEW_FLDR
git filter-branch --prune-empty --subdirectory-filter ‘FLDR_TO_KEEP’ master
git remote rm origin
git update-ref -d refs/original/refs/heads/master
git reflog expire --expire=now --all
git repack -ad
git reset --hard
git gc --aggressive --prune=now
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment