Created
November 5, 2010 09:53
-
-
Save olivierverdier/663902 to your computer and use it in GitHub Desktop.
Create a new repo containing only one file
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 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