我正在寻找与 git commit -am "blah blah"
等效的方法,但只是针对单个文件。如果我尝试:
git commit my.file -am "blah blah"
我得到:
fatal: Paths with -a does not make sense.
我环顾四周,但只能找到建议使用别名的解决方案(例如 this one ),但即使是那些似乎也无法修改,因为我需要传递一个参数。我是否必须求助于 calling git through a shell ?
对于我认为非常常见的事情,似乎应该有一个更简单的选择。现在我坚持:
git add my.file
git commit -m "blah blah"
最佳答案
只需省略 -a
这意味着 --all
这不是您想要的。这样做:
git commit my.file -m "blah blah"
这将仅提交 my.file
,即使其他文件已暂存(通过 git add
)也是如此。
关于git 在一个命令中添加并提交单个跟踪文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26407059/