我能做点什么吗

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 add . && git commit -am "comment"

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

其他回答

我有这个函数在我的。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"
}

我使用以下方法(这两种方法都在进行中,所以我会尽量记得更新):

# Add All and Commit
  aac = !echo "Enter commit message:" && read MSG && echo "" && echo "Status before chagnes:" && echo "======================" && git status && echo "" && echo "Adding all..." && echo "=============" && git add . && echo "" && echo "Committing..." && echo "=============" && git commit -m \"$MSG\" && echo "" && echo "New status:" && echo "===========" && git status

# Add All and Commit with bumpted Version number
  aacv = !echo "Status before chagnes:" && echo "======================" && git status && echo "" && echo "Adding all..." && echo "=============" && git add . && echo "" && echo "Committing..." && echo "=============" && git commit -m \"Bumped to version $(head -n 1 VERSION)\" && echo "" && echo "New status:" && echo "===========" && git status

呼应“Enter commit message:”&&读取MSG部分,灵感来自Sojan V Jose

我想在那里得到一个if else语句,这样我就可以让aacv问我,如果我想部署时,如果我键入'y',为我这样做,但我想我应该把它放在我的.zshrc文件

我使用这个git别名:

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

所以,不是打电话

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

我只会:

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

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

要保持在一行中使用:

Git commit -am "comment"

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

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

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

你可以使用-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.