我能做点什么吗

git add -A
git commit -m "commit message"

一个命令?

我似乎经常使用这两个命令,如果Git有一个像Git commit -Am“commit message”这样的选项,它会让生活变得更方便。

git commit有-a修饰符,但它不完全等同于在提交前执行git add -a。git add -A添加新创建的文件,但git commit -am不添加。什么?


当前回答

你可以使用-a

git commit -h

...
Commit contents options
    -a, -all    commit all changed files
...

git commit -a # It will add all files and also will open your default text editor.

其他回答

对于人群中的银背,他们习惯了Subversion……我通常在我的项目的根目录中添加如下内容(在windows中作为一个bat文件,例如git-commit.bat)。然后当我想添加、提交和推送时,我只需输入git-commit“添加了一些新东西”这样的东西,它就会全部到远程回购。

此外,这样项目中的任何人都可以使用相同的,而不必在本地更改任何内容。

我通常也运行git配置凭证。helper存储一次,所以我不需要给uid/pwd时,这是运行。

::
:: add, commit, and push to git
::

@echo off
echo.
echo.
echo 
echo Doing commit...
git add -A && git commit -m %1
echo.
echo.
echo Doing push...
git push
echo.
echo.
echo Done.
echo.

要保持在一行中使用:

git add . && git commit -am "comment"

这一行将添加并提交所有更改和添加的文件到存储库。

只适应Ales的回答和courtsimas的评论linux bash:

要保持在一行中使用:

Git commit -am "comment"

这一行将添加并提交所有更改到存储库。

只要确保没有git还未拾取的新文件就可以了。否则你需要使用:

Git添加。; Git commit -am "message"

很确定你可以用:

git commit -am "commit all the things"

您可以使用git别名,例如:

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

用在

git add-commit -m 'My commit message'

EDIT:返回到ticks('),否则在Linux上shell扩展将失败。在Windows上,应该使用双引号(")来代替(在评论中指出,没有验证)。