Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
git在一个命令中添加并提交单个跟踪文件_Git_Alias - Fatal编程技术网

git在一个命令中添加并提交单个跟踪文件

git在一个命令中添加并提交单个跟踪文件,git,alias,Git,Alias,我正在寻找与git commit-am“blah blah”等效的文件,但只需要一个文件。如果我尝试: git commit my.file -am "blah blah" 我得到: fatal: Paths with -a does not make sense. 我环顾四周,但我只能找到建议使用别名的解决方案(例如,),但即使是那些别名也似乎无法修改,因为我需要传递一个参数。我必须求助于 似乎应该有一个更简单的选择,我认为这是非常普遍的。现在我被困在: git add my.file g

我正在寻找与git commit-am“blah blah”等效的文件,但只需要一个文件。如果我尝试:

git commit my.file -am "blah blah"
我得到:

fatal: Paths with -a does not make sense.
我环顾四周,但我只能找到建议使用别名的解决方案(例如,),但即使是那些别名也似乎无法修改,因为我需要传递一个参数。我必须求助于

似乎应该有一个更简单的选择,我认为这是非常普遍的。现在我被困在:

git add my.file
git commit -m "blah blah"

只需省略
-a
,它的意思是
-all
,而这不是您想要的。这样做:

git commit my.file -m "blah blah"

这将仅提交
my.file
,即使其他文件已暂存(通过
git add
)。

我尝试了以下命令:

git commit -m 'your comment' path/to/your/file.txt

我希望,这会有帮助。

天哪,真不敢相信事情会这么简单。我没有意识到我可以在没有暂存的情况下进行提交(消息“Changes not staged for commit:”把我甩了)。难怪没有人问这个问题。。。我还解释了-a的意思是
add
。这将提交文件,即使它尚未由
git add
暂存。(一开始我不相信这一点——尽管在问题中和上面的评论(!)中都提到了它,所以在这里明确地提到了它。)但是,如果一个文件还没有被跟踪,这将不会提交它。这与2016年被接受的答案基本相同。另外,你的回答是“我试过了”,但没有关于这是否真的有效的信息。因此,这个答案不仅没有必要,而且也不是一个很好的答案。