在 git 中提交时如何更正错误:pathspec 消息?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4133138/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how do I correct the error: pathspec message when committing in git?
提问by Mild Fuzz
I am trying to commit changes with the command git commit "commit message"
to a local branch, but am getting the following message:
我正在尝试使用命令git commit "commit message"
将更改提交到本地分支,但收到以下消息:
error: pathspec 'commit message' did not match any file(s) known to git.
回答by Mark Rushakoff
It's git commit -m "commit message"
. You're missing the -m
flag.
它是git commit -m "commit message"
。你错过了-m
国旗。
回答by user2018766
If you're using Windows you need to use double quotes
如果您使用的是 Windows,则需要使用双引号
回答by Xu Cao
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"'
在 Windows 上使用双引号非常好。我花了几个小时试图弄清楚为什么单引号不起作用。谢谢!根据我自己的经验,我想在这里提到的一件事是,出于某种原因,您似乎仍然必须执行 'git commit -a',以便稍后能够推送到远程 git 存储库,例如 'git push'。并且几乎没有意义只执行 'git commit -m "commit message..."' 因为当你在 Windows 上执行 'git commit -a' 时,无论如何你都会在 vi 编辑器中再次输入它。我认为只有在 Windows 上你才需要做 'git commit -a' 而不仅仅是 'git commit -m "msg"'