{"thread":{"id":"13096","subject":"git-rm fu","startedAt":"2008-04-13T20:44:45Z","lastAt":"2008-04-13T20:44:45Z","messageCount":1,"participants":["Jon Loeliger"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"74271","messageId":"E1Jl949-0000yh-M1@jdl.com","threadId":"13096","inReplyTo":null,"subject":"git-rm fu","fromName":"Jon Loeliger","fromEmail":"jdl@jdl.com","sentAt":"2008-04-13T20:44:45Z","receivedAt":"2008-04-13T20:44:45Z","isPatch":false,"sender":{"key":"jdl@jdl.com","avatar":"https://gravatar.com/avatar/75ce9a10b151acd2c28ec4ab2136dba7b2ff1634530bd04b155981a749d08a64?d=mp&s=160"},"body":"\nGiven:\n\n$ git init\nInitialized empty Git repository in .git/\n$ echo one >> git-foo.sh\n$ mkdir subdir\n$ echo two >> subdir/git-foo.sh\n$ mkdir subdir/snizzle\n$ echo three >> subdir/snizzle/git-foo.sh\n$ git add .\n$ git commit -m\"All quiet on the western front.\"\nCreated initial commit 15fe70d: All quiet on the western front.\n 3 files changed, 3 insertions(+), 0 deletions(-)\n create mode 100644 git-foo.sh\n create mode 100644 subdir/git-foo.sh\n create mode 100644 subdir/snizzle/git-foo.sh\n\nThe \"git rm\" manual's second example says:\n\n    git-rm -f git-*.sh\n\n        Remove all git-*.sh scripts that are in the index. Because this\n        example lets the shell expand the asterisk (i.e. you are listing\n        the files explicitly), it does not remove subdir/git-foo.sh.\n\nIt is not true that this command will remove all git-*.sh scripts\nthat are in the index.  Here are three:\n\n    $ git ls-files\n    git-foo.sh\n    subdir/git-foo.sh\n    subdir/snizzle/git-foo.sh\n\nUsing -f on this command is a red herring.  Using -f or -n\ndoesn't matter, and since we want to do more than one command\nhere, I'm just going to show it all using -n:\n\nThe effect of the command is to match just one file at the top level:\n\n    $ git rm -n git-*.sh\n    rm 'git-foo.sh'\n\nFurthermore, there is an implication in the wording of the\nsecond example that suggests that if you had let git expand the\nfile glob, the subdir/git-foo.sh file would have been removed.\n\nAlso not true:\n\n    $ git rm -n git-\\*.sh\n    rm 'git-foo.sh'\n\nTo actually get the behavior of \"removing all git-*.sh scripts\nfrom the index\", you have to prefix a file glob at the front\nof the paths to match directories too:\n\n    $ git rm -n \\*git-\\*.sh\n    rm 'git-foo.sh'\n    rm 'subdir/git-foo.sh'\n    rm 'subdir/snizzle/git-foo.sh'\n\nBut then, using any of:\n\n        \\*git-\\*.sh\n        \\*git-*.sh\n        *git-\\*.sh\n\nall effectively *will* match subdir/git-foo.sh:\n\n    $ git rm -n \\*git-*.sh\n    rm 'git-foo.sh'\n    rm 'subdir/git-foo.sh'\n    rm 'subdir/snizzle/git-foo.sh'\n\n    $ git rm -n *git-\\*.sh\n    rm 'git-foo.sh'\n    rm 'subdir/git-foo.sh'\n    rm 'subdir/snizzle/git-foo.sh'\n\nSo it seems that the two parts discussed in the second example\nare really unrelated.\n\nIt seems like \"git rm d2/*\" should remove all of d2's files\nwithout trying to recursively remove any subdirectories,\nbut it won't:\n\n    $ git rm -n d2/*\n    fatal: not removing 'd2/two' recursively without -r\n\nBut then using -r force d2/two/ to be removed as well:\n\n    $ git rm -n d2/\\*\n    rm 'd2/two/xyzzy'\n    rm 'd2/x'\n    rm 'd2/y'\n    rm 'd2/z'\n\nThere's no real way to say \"just the files in d2/\".\n\n(Yeah, sure, I could have said \"git rm d2/\\?\", but that wouldn't\nwork if d2/xyzzy existed too. :-))\n\njdl\n"}]}