Re: Unexpected recursion in 'git rm'
- From
- Mikael Magnusson <mikachu@gmail.com>
- Date
- Jul 3, 2026, 15:25 UTC
- Message-ID
- <CAHYJk3RXY5-YgcYWY2y8vOcHG5Frf91ehNiZRr66sJJH5F=qLQ@mail.gmail.com>
- In-Reply-To
- <323134122.20260702104910@gmail.com>
On Thu, Jul 2, 2026 at 9:51 AM Евгений Плискин <eugene.pliskin@gmail.com> wrote:
Show 10 quoted lines
> > Hello. > > The following git command does recurse directories as contrary to the reference (https://git-scm.com/docs/git-rm): > > git rm -n *.json > > Without directory specification before '*.json' this command is not expected to recurse directories, but it really does. > > git version 2.55.0.windows.1
I can't see any formulation in the manpage reference that suggests it wouldn't recurse, though you might overall get less surprised if you set the failglob option in bash. Then the shell would notice *.json has no matches, and you'd have to say git rm -n '*.json' to let git process the glob instead of the shell. See also https://git-scm.com/docs/gitglossary (as referenced from the git-rm page) which says:
the rest of the pathspec is a pattern for the remainder of the pathname. Paths relative to the directory prefix will be matched against that pattern using fnmatch(3); in particular, * and ? can match directory separators.
-- Mikael Magnusson