Git在一个命令中添加和提交 [英] Git add and commit in one command
问题描述
有什么办法可以做吗?
git add -A
git commit -m提交信息
在一个命令中?
我似乎在做这两个命令,如果Git有一个像 您可以使用git别名,例如 并将它与 git commit -Amcommit message的选项$
$ b git commit
具有,这会让生活变得更加方便。 c> -a
修饰符,但它在提交之前与 git add -A
不完全相同。 git add -A
会添加新创建的文件,但 git commit -am
不会。
git config --global alias.add-commit'!git add -A&& git commit'
git add-commit -m'我的提交消息'
编辑:恢复为ticks('),否则它将在Linux上进行shell扩展失败。 在Windows 上,应该使用双引号()(在评论中指出,未验证)。
Is there any way I can do
git add -A
git commit -m "commit message"
in one command?
I seem to be doing those two commands a lot, and if Git had an option like git commit -Am "commit message"
, it would make life that much more convenient.
git commit
has the -a
modifier, but it doesn't quite do the same as doing git add -A
before committing. git add -A
adds newly created files, but git commit -am
does not. What does?
You can use git aliases, e.g.
git config --global alias.add-commit '!git add -A && git commit'
and use it with
git add-commit -m 'My commit message'
EDIT: Reverted back to ticks ('), as otherwise it will fail for shell expansion on Linux. On Windows, one should use use double-quotes (") instead (pointed out in the comments, did not verify).
这篇关于Git在一个命令中添加和提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!