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

GitCommand Line

Git Problem Overview


I am trying to upload a Ruby app to Heroku. I start with git init and then I type git add . and then I use git commit -m initial commit.

Whenever I use git commit -m, I receive an error message saying:

> git commit error:pathspect 'commit' did not match any file(s) known to git.

I have been told that this is happening because the arguments are in the wrong order.

The thing I noticed is that when I use git add . it will not list the files that are being added because it will just go to the next line.

I suspect that I am having this problem because my files are not really being added.

I would appreciate any advice about how to correct this problem.

Git Solutions


Solution 1 - Git

The command line arguments are separated by space. If you want provide an argument with a space in it, you should quote it. So use git commit -m "initial commit".

Solution 2 - Git

I would just like to add--

In windows the commit message should be in double quotes (git commit -m "initial commit" instead of git commit -m 'initial commit'), as I spent about an hour, just to figure out that single quote is not working in windows.

Solution 3 - Git

In my case, this error was due to special characters what I was considering double quotes as I copied the command from a web page.

Solution 4 - Git

I figured out mistake here use double quotations instead of single quotations.

change this

git commit -m 'initial commit'

to

git commit -m "initial commit"

Solution 5 - Git

Had this happen to me when committing from Xcode 6, after I had added a directory of files and subdirectories to the project folder. The problem was that, in the Commit sheet, in the left sidebar, I had checkmarked not only the root directory that I had added, but all of its descendants too. To solve the problem, I checkmarked only the root directory. This also committed all of the descendants, as desired, with no error.

Solution 6 - Git

Had this happen to me when committing from Xcode 6, after I had added a directory of files and subdirectories to the project folder. The problem was that, in the Commit sheet, in the left sidebar, I had checkmarked not only the root directory that I had added, but all of its descendants too. To solve the problem, I checkmarked only the root directory. This also committed all of the descendants, as desired, with no error.

Solution 7 - Git

I have encounter the same problem. my syntax has no problem. What I found is that I copied and pasted git commit -m "comments" from my note. I retype it, the command execute without issue. It turns out the - and " " are the problem when I copy paste to terminal.

Solution 8 - Git

In my case, the problem was I used wrong alias for git commit -m. I used gcalias which dit not meant git commit -m

Solution 9 - Git

if there are anybodys using python os to invoke git,u can use os.system('git commit -m " '+str(comment)+'"')

Solution 10 - Git

In my case the problem was I had forgotten to add the switch -m before the quoted comment. It may be a common error too, and the error message received is exactly the same

Solution 11 - Git

Solved! Here is how I solved this issue:

  1. Made an app on Heroku first and prepared all the codes in local_folder to push into it.
  2. Cloned the remote app using heroku git:clone -a app_name
  3. then cd app_name
  4. then copied all the codes into this folder from local_folder
  5. then git add .
  6. then git commit -am "initial commit"
  7. then git push heroku master
  8. Viola!

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionuser2457644View Question on Stackoverflow
Solution 1 - GitkanView Answer on Stackoverflow
Solution 2 - GitNicksView Answer on Stackoverflow
Solution 3 - GitzeeawanView Answer on Stackoverflow
Solution 4 - Gitsaigopi.meView Answer on Stackoverflow
Solution 5 - GitLinux_GoogleView Answer on Stackoverflow
Solution 6 - GitJerry KrinockView Answer on Stackoverflow
Solution 7 - GitHaibin ChenView Answer on Stackoverflow
Solution 8 - GitT GView Answer on Stackoverflow
Solution 9 - Git未来陆家嘴顶尖的投资人View Answer on Stackoverflow
Solution 10 - GitJavier D.View Answer on Stackoverflow
Solution 11 - GitDeepak MittalView Answer on Stackoverflow