Skip to content

Instantly share code, notes, and snippets.

@MrSaints
Created October 17, 2014 02:44
Show Gist options
  • Save MrSaints/269adaa4e2a46259bf31 to your computer and use it in GitHub Desktop.
Save MrSaints/269adaa4e2a46259bf31 to your computer and use it in GitHub Desktop.
Transfers a Git file from one repository to another while maintaining its Git history.
git filter-branch --prune-empty --subdirectory-filter <DIRECTORY TO FILTER> -- --all
git filter-branch -f --prune-empty --index-filter 'git rm --cached --ignore-unmatch $(git ls-files | grep -v "<FILE TO FILTER>")'
git reset --hard
git remote rm origin
git gc --aggressive
git prune
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment