-2

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?

closed as off-topic by Jeff Schaller, jasonwryan, mosvy, RalfFriedl, G-Man Nov 14 '18 at 6:49

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions describing a problem that can't be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." – Jeff Schaller, jasonwryan, mosvy, RalfFriedl, G-Man
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 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
3

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.

  • 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.