You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Some thoughts on Ch 7, "The Nuclear Option: filter-branch" #825
One or more things I'm thinking of adding/clarifying.
First, that initial example of removing the file "passwords.txt" doesn't make it clear that that specific command will only remove that file in the root directory of the repo. The text says simply, "To remove a file named passwords.txt ..." [emphasis added]; perhaps the command should be tweaked to remove the file "/passwords.txt", or "/path/to/passwords.txt" to make it clear it has to be precise.
Second, I think it's important to mention (and I can add this) that the command needs to be "rm -f" to ensure that commits that don't contain that file will not cause the process to abort.
Finally (and I've already changed this), the example of removing backup editor files should be changed from "rm -f" to "rm -rf", obviously to remove all of those files recursively, yes?
Anything more advanced with filter-branch is, I think, beyond the scope of the book.
By this point in the book, I think it should be clear to a reader that if we don't mention the full path to a file, then it's in the root directory of the repository. I don't think a change is necessary.
Yes, you're absolutely right.
Well, rm -rf doesn't do what you want it to either. The command as it is suggested (git filter-branch --tree-filter 'rm -f *~' HEAD) does what it needs to do, which is to plant the idea that you don't have to live with those files in your repo forever. Anyone looking to do this sort of thing will already know that that command won't find backup files in subdirectories, and will do the find . -name "*~" | xargs… magic themselves. I don't want to get bogged down in BASH perfectionism in this section, it's not about that.
Agreed. There are tons of examples in the manpage for those looking to dig deeper.
Activity
ben commentedon Oct 3, 2017
rm -rfdoesn't do what you want it to either. The command as it is suggested (git filter-branch --tree-filter 'rm -f *~' HEAD) does what it needs to do, which is to plant the idea that you don't have to live with those files in your repo forever. Anyone looking to do this sort of thing will already know that that command won't find backup files in subdirectories, and will do thefind . -name "*~" | xargs…magic themselves. I don't want to get bogged down in BASH perfectionism in this section, it's not about that.