When I looked at Pro Git, I was frightened by the author's nickname "Nuke-Class option", so I never dared to try it curiously. Nuclear bombs, with the right to the infinite, with the wrong destructive power infinite!
But today, I had to use it because I wanted to put some of my original code on GitHub and go public. Since did not want to public before, to upload only found that can not upload more than 50M files.
Toss for a while, still can't upload, so, the whole command came out:
git filter-branch--tree-filter'RM-RF Files_to_remove'--prune-empty-f HEAD--all
The command is quite complicated, so I am in a clone out of the warehouse first try to run. First explain the following parameters:
--tree-filter
Represents a list of modified files.
--msg-filter
Represents the modification of the submission information, the original submission is read from the standard input, the new submission output to the standard output.
--prune-empty
Indicates that if the modified commit is empty, discard it. In a trial run I found that although the file was deleted, but also left an empty commit, the next man document, found this option.
-f
is to ignore the backup. Without this option, the second time you run this command, you'll get an error, meaning that git did the last backup, and now you have to run it to get rid of the last backup.
--all
is for all branches.
Try running a few times, see more than 40 commits are rewritten, and then check to see that the files to be deleted are indeed deleted. So happily to GitHub to build a new warehouse, and uploaded.
Toss it over, I like git more:-)
"Nuke-level options" for the first time using git: filter-branch delete files from the repository