Skip to content

Instantly share code, notes, and snippets.

@VojtechVitek
Forked from olavmrk/removeexcept.sh
Created April 14, 2020 12:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save VojtechVitek/e4f218865c0e7181f9cf264e1a1f3ebe to your computer and use it in GitHub Desktop.
Save VojtechVitek/e4f218865c0e7181f9cf264e1a1f3ebe to your computer and use it in GitHub Desktop.
git filter-branch command to remove all files except those of interest
# Remove every file except "./somefile.txt" and the directory "./somedir".
# --prune-empty to remove empty commits.
git filter-branch --tree-filter "find . -not -path './.git' -not -path './.git/*' -not -path './somefile.txt' -not -path './somedir/*' -not -path './somedir' -delete" --prune-empty
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment