bashgitgit-pathspec

Git won't add certain globs


I'm left scratching my head on this one. So, in git on OSX, you can add files like:

git add *.java

and it will add all files that have the *.java extension. Same for .txt, json, etc. However, when I do a

git add *.xml

nothing happens. It's not specified in my gitignore, so git is reporting it as changed with a git status, but I can't seem to add with the globbing pattern.

I'm not asking HOW to recursively add files by pattern, git, (or bash?) already does that, as explained in my first example.

System:


Solution

  • Quote the glob so that it passed to git for processing, rather than expanded by the shell.

    git add '*.xml'