Skip to content

Some thoughts on Ch 7, "The Nuclear Option: filter-branch" #825

Open

Description

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.

Activity

  1. ben commented on Oct 3, 2017

    @ben
    Member
    1. 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.
    2. Yes, you're absolutely right.
    3. 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.
    4. Agreed. There are tons of examples in the manpage for those looking to dig deeper.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions