我尝试了以下命令:
git commit path/to/my/file.ext -m 'my notes'
在Git版本1.5.2.1中收到一个错误:
error: pathspec '-m' did not match any file(s) known to git.
error: pathspec 'MY MESSAGE' did not match any file(s) known to git.
这是单个文件或目录提交的错误语法吗?
我尝试了以下命令:
git commit path/to/my/file.ext -m 'my notes'
在Git版本1.5.2.1中收到一个错误:
error: pathspec '-m' did not match any file(s) known to git.
error: pathspec 'MY MESSAGE' did not match any file(s) known to git.
这是单个文件或目录提交的错误语法吗?
当前回答
在输入的提交消息后指定路径,例如:
git commit -m "commit message" path/to/file.extension
其他回答
对于Windows 7上的Git 1.9.5:“my Notes”(双引号)更正了这个问题。在我的例子中,把文件放在-m 'message'之前或之后没有区别;使用单引号是问题所在。
Try:
git commit -m 'my notes' path/to/my/file.ext
如果您在当前目录中,则将./添加到路径前面;
git commit -m 'my notes' ./path/to/my/file.ext
使用-o选项。
git commit -o path/to/myfile -m "the message"
-o,——only只提交指定的文件
Suppose you are working on big project and have opened multiple files, and you made changes in single file, when you don't need to write git add ., this will add all the files to git, so you first need to check where you made changes by git status, here you will see all the paths next to the filenames, copy the path of the file where you made change and then write git add path, here path is whole line of path to the file (your modified file). Then you write your commit message by git -m "message" and then push.
这将只推送你在git add file中使用过的指定文件
你的论点顺序不对。尝试git commit -m 'my notes' path/to/my/file。Ext,或者更明确地说,git commit -m 'my notes'——path/to/my/file.ext。
顺便提一下,Git v1.5.2.1已经有4.5年的历史了。您可能希望更新到较新的版本(1.7.8.3是当前版本)。