Git: cannot checkout branch - error: pathspec '…' did not match any file(s) known to git

后端 未结 30 3279
太阳男子
太阳男子 2020-11-27 23:54

I\'m not sure why I\'m unable to checkout a branch that I had worked on earlier. See the commands below (note: co is an alias for checkou

30条回答
  •  無奈伤痛
    2020-11-28 00:42

    I encountered this same issue when I was first playing around with git. When attempting my first commit...

    git commit -m 'first commit!'
    

    I got the error mentioned by the OP...

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

    I thought I might have been confusing git by using a keyword in the commit message, so I tried a few other words and received the same error.

    Finally I used double-quotes in the message...

    git commit -m "first commit!"
    

    This turned out to be successful...

    [master (root commit) 0000000] first commit!
    1 file changed, 0 insertions(+), 0 deletions(-)
    create mode 100644 dummyDoc.txt
    

提交回复
热议问题