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

后端 未结 12 1442
北海茫月
北海茫月 2021-01-30 08:04

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

相关标签:
12条回答
  • 2021-01-30 08:23

    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.

    0 讨论(0)
  • 2021-01-30 08:26

    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"

    0 讨论(0)
  • 2021-01-30 08:26

    Please take note that in windows, it is very important that the git commit -m "initial commit" has the initial commit texts in double quotes. Single quotes will throw a path spec error.

    0 讨论(0)
  • 2021-01-30 08:29

    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.

    0 讨论(0)
  • 2021-01-30 08:32

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

    0 讨论(0)
  • 2021-01-30 08:33

    Please try adding the double quotes git commit -m "initial commit". This will solve your problem.

    0 讨论(0)
提交回复
热议问题