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


当前回答

我使用这个函数:

gcaa() { git add --all && git commit -m "$*" }

在我的zsh配置文件,所以我可以做:

> gcaa This is the commit message

自动执行并提交所有文件。

其他回答

我使用这个函数:

gcaa() { git add --all && git commit -m "$*" }

在我的zsh配置文件,所以我可以做:

> gcaa This is the commit message

自动执行并提交所有文件。

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

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"

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

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

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

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

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用于限制 更新到当前目录及其子目录)。