32

I am trying to commit changes with the command git commit "commit message" to a local branch, but am getting the following message:

error: pathspec 'commit message' did not match any file(s) known to git. 
2
  • This can also happen, if you forgot to add some new files. So, first the files needs to be added with git add ... Commented Feb 7, 2018 at 9:57
  • 1
    Alternatively, while using Vscode double quotes didn't work for me, it was single quotes. Commented Feb 11, 2021 at 17:39

3 Answers 3

58

It's git commit -m "commit message". You're missing the -m flag.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks. I have been looking for this solution on the whole Internet because I was doing git commit --amend 'commit message' instead of git commit --amend -m 'commit message'. I had found solutions involving double quotes, but which were totally unrelated to my problem.
35

If you're using Windows you need to use double quotes

1 Comment

Thank you, it took some time to recognize the qoutes-issue after background in Linux.
2

Very Good point using double quotes on windows. It cost me hours trying to figure out why the single quote didn't work. Thank you! One thing I want to mention here from my own experience is it seems you still have to do 'git commit -a' for some reason to be able later on to push to the remote git repo such as 'git push'. and it's almost no point doing just 'git commit -m "commit message..."' coz you will type it up in a vi editor again anyway when you do 'git commit -a' on windows. I think only on windows you need to do 'git commit -a' instead of just 'git commmit -m "msg"'

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.