Skip to content

Instantly share code, notes, and snippets.

@ptrv
Created January 17, 2010 22:18
Show Gist options
  • Save ptrv/279621 to your computer and use it in GitHub Desktop.
Save ptrv/279621 to your computer and use it in GitHub Desktop.
Splitting git repository.
============
* Do the clone and the filter:
`git clone --no-hardlinks foo bar; cd bar`
`git filter-branch --subdirectory-filter subdir/you/want HEAD`
* Remove every reference to the old history. "origin" was keeping
track of your clone, and “original” is where filter-branch saves
the old stuff:
`git remote rm origin`
`rm -r .git/refs/original/`
`git reflog expire --expire=now --all`
* Even now, your history might be stuck in a packfile that fsck won't touch. Tear it to shreds:
`git gc --aggressive`
* Only now does git-fsck find unused commits! Now git-prune will delete them:
`git prune`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment