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


当前回答

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

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

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

git foo

简单地说一下

git coa "my changes are..."

Coa代表“全部承诺”

其他回答

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

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 -am  "<commit message>"

源自man git-commit:

-a, --all
    Tell the command to automatically stage files that have been modified
    and deleted, but new files you have not told Git about are not
    affected.

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

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

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

很棒的答案,但如果你寻找一行做所有,你可以连接,别名和享受的便利:

Git add * && Git commit -am "<提交消息>"

它是一个单行,但有两个命令,如前所述,你可以别名这些命令:

别名git-aac="git add * && git commit -am "(末尾的空格很重要),因为你要参数化新的短手命令。

从现在起,你要用这个别名

Git-acc "<提交消息>"

你基本上会说:

Git,为我添加所有未跟踪的文件,并使用这个给定的提交消息提交它们。

希望你使用Linux,希望这对你有帮助。