如何使用一个命令来提交所有文件,包括新添加的文件?


当前回答

我认为这是展示和提交所有更改的最优雅的方式:

git commit -am  "message"

其他回答

运行所有文件(修改、删除和新建)并提交注释的一行程序:

git add --all && git commit -m "comment"

http://git-scm.com/docs/git-add http://git-scm.com/docs/git-commit

我不知道为什么这些答案都围绕着我所认为的正确解决方案,但为了它的价值,我在这里使用:

1. 创建别名:

git config --global alias.coa '!git add -A && git commit -m'

2. 添加所有文件并提交一个消息:

git coa "A bunch of horrible changes"

注意:coa是commit all的缩写,可以替换为任何你想要的东西

我在我的配置中有两个别名:

alias.foo=commit -a -m 'none'
alias.coa=commit -a -m

如果我太懒,我就提交所有的更改

git foo

简单地说一下

git coa "my changes are..."

Coa代表“全部承诺”

最简单的方法是使用下面的命令来添加并提交更改:

git commit -a -m "your commit message"

警告:这将不会提交未跟踪的文件

Does

git add -A && git commit -m "Your Message"

算作“单一命令”?

根据下面@thefinnomenon的回答进行编辑

要将它作为git别名,请使用:

git config --global alias.coa "!git add -A && git commit -m"

并提交所有文件,包括新文件,用一个消息:

git coa "A bunch of horrible changes"

解释

从git添加文档:

-A, -所有,-no-ignore-removal 不仅在工作树中有文件匹配的地方更新索引,而且在索引已经有文件匹配的地方更新索引 条目。属性的添加、修改和删除索引项 工作树。 如果使用-A选项时没有给出<pathspec>,则 更新整个工作树(旧版本的Git用于限制 更新到当前目录及其子目录)。