Skip to content

Instantly share code, notes, and snippets.

@olivierverdier
Created November 5, 2010 09:53
Show Gist options
  • Save olivierverdier/663902 to your computer and use it in GitHub Desktop.
Save olivierverdier/663902 to your computer and use it in GitHub Desktop.
Create a new repo containing only one file
# remove all the files but the file named "my_file.py":
git filter-branch -f --prune-empty --tree-filter 'find . ! -type d | grep -v "./my_file.py$" | while read FILE; do rm "$FILE"; done' HEAD
# if there are still empty commit despite the --prune-empty option, remove them:
git filter-branch --commit-filter 'if [ z$1 = z`git rev-parse $3^{tree}` ]; then skip_commit "$@"; else git commit-tree "$@"; fi' "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment