我尝试了以下命令:
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.
这是单个文件或目录提交的错误语法吗?
当前回答
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中使用过的指定文件
其他回答
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 "Commit message" -- filename.ext
你的论点顺序不对。尝试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是当前版本)。
Try:
git commit -m 'my notes' path/to/my/file.ext
如果您在当前目录中,则将./添加到路径前面;
git commit -m 'my notes' ./path/to/my/file.ext
在输入的提交消息后指定路径,例如:
git commit -m "commit message" path/to/file.extension