Created
February 15, 2017 20:57
-
-
Save wilsonianb/67732894ddc1cf00367013b2f47db353 to your computer and use it in GitHub Desktop.
git-filter-branch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Remove everything except specific files/directories | |
git filter-branch -f --prune-empty --index-filter \ | |
'git rm --cached -r -q -- . ; git reset -q $GIT_COMMIT -- my-file my-dir' -- --all | |
# Remove specified files/directories | |
git filter-branch --index-filter 'git rm -r --cached --ignore-unmatch my-file my-dir' HEAD | |
# Move file | |
git filter-branch --tree-filter ' | |
if [ -f current-dir/my-file ]; then | |
mv current-dir/my-file new-dir/ | |
fi' --force HEAD | |
# Reduce repo to specified directory | |
git filter-branch --subdirectory-filter my-fav-dir -- --all |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment