我能做点什么吗

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不添加。什么?


当前回答

你可以使用

git commit -am "[comment]" # best solution 

or

git add . && git commit -m "[comment]"

其他回答

我希望这能帮助到一些人,请随意编辑或改进。我不知道最快的方法是什么,但这确实简化了我的代码提交过程使用“ohmyzsh”Git。

https://ohmyz.sh/

Git添加。缩写为ga。 Git commit -m "message"缩写为gc -m "message" Git push被缩短为gp Git取回被缩短为gf Git拉源master缩短为GGL master Git push origin master被缩短为GGP master Git checkout -b缩写为GCB Git merge缩写为gm Git remote缩写为gr Git状态缩短为GST

我使用这个git别名:

Git配置——全局别名。凸轮”!Git提交-a -m '

所以,不是打电话

git add -A && git commit -m "this is a great commit"

我只会:

Git CAM“这是一个伟大的承诺”

只使用:

git commit -m "message" .     

注意结尾的"."…也可以是文件/目录的路径

在git的后期版本中,您可以像这样添加和提交

git commit -a -m "commit message"

另外你还有一个别名:

[alias]
    ac = commit -a -m

然后你可以这样使用它:

git ac "commit message"

我有这个函数在我的。bash_profile或。profile或。zprofile或任何登录shell中的来源:

function gac () {
  # Usage: gac [files] [message]
  # gac (git add commit) stages files specified by the first argument
  # and commits the changes with a message specified by the second argument.
  # Using quotes one can add multiple files at once: gac "file1 file2" "Message".
  git add $1 && git commit -m "$2"
}