I am not sure what is going wrong (terminal, shell, system?), but when I enter:

git commit -m "My commit message"

this morning, I get:

error: pathspec 'My' did not match any file(s) known to git
error: pathspec 'commit' did not match any file(s) known to git
error: pathspec 'message' did not match any file(s) known to git

I have just updated iTerm2 yesterday, that's all I remember changing recently. I'm on MacOS High Sierra 10.13.6 (not a recent update). My version of git is 2.19.1, bash is GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin17) and iTerm2 is Build 3.2.5.

I tried in the Apple provided Terminal utility 2.8.2 (404), with the same bash and git and got the same error.

Updated bash to GNU bash, version 4.4.23(1)-release (x86_64-apple-darwin17.5.0) and got the same error.

git is not alias. echo "My Commit" works. git commit -m "MyCommit" works.

Trying in csh... git commit -m "My Commit" works in csh!!! So somehow it is a bash thing? What bash setting could lead to that?

  • 2
    What Version of git are you running? git --version – thebtm Nov 13 '18 at 17:56
  • 1
    My version of git is: 2.19.1. – Frank Nov 13 '18 at 18:09
  • Added version details to OP. – Frank Nov 13 '18 at 18:20
  • Try the command in another shell, another terminal application. This will hopefully narrow the problem. – Kamil Maciorowski Nov 13 '18 at 18:24
  • 3
    Is git an alias? Check with eg typ git. Try also the command withe the word command first, ie, command git commit -m etc. . – Kusalananda Nov 13 '18 at 19:18

Found it. I had a function in my ~/.bash_profile that looked like:

git ()
  /usr/local/bin/git $*

which was intending to use a more recent version of git than the one provided by MacOS. The handling of the arguments in that function definition is wrong.

| improve this answer | |
  • 7
    Should be "$@" (with the double quotes) instead of unquoted $*. But you could just have done alias git=/usr/local/bin/git, or include /usr/local/bin early in your $PATH. – Kusalananda Nov 13 '18 at 20:19

Not the answer you're looking for? Browse other questions tagged or ask your own question.