Git在一个命令中添加并提交

有什么办法能够作吗 git

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

在一个命令中? bash

我彷佛常常执行这两个命令,而且若是Git具备git commit -Am "commit message"类的选项,它将使生活变得更加便捷。 this

git commit具备-a修饰符,但与提交以前执行git add -Agit add -A添加新建立的文件,可是git commit -am不添加。 什么事 spa


#1楼

只需结合您的命令: 线程

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

#2楼

在个人Windows计算机上,我设置了这个.bashrc别名,以使整个过程更加简单。 code

  • 建立/定位您的.bashrc 引用SO线程
  • 将如下行添加到文件 部署

    alias gacp='echo "enter commit message : " && read MSG && git add . && git commit -m "$MSG" && git push'

    它确实git add commit和push。 以任何方式对其进行调整,例如您不但愿push命令删除该部分 get

  • 从新加载.bashrc /关闭并从新打开外壳 it

  • 如今,您可使用gacp命令完成整个过程。

#3楼

我使用这个git别名: io

git config --global alias.cam '!git commit -a -m '

因此,而不是打电话

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

我只是作:

git cam "this is a great commit"


#4楼

要将其保持为一行,请使用:

gacm "your comment"

#5楼

我使用如下方法(二者都在进行中,因此我会尽可能记住进行更新):

# 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

经过echo "Enter commit message:" && read MSG受Sojan V Jose启发的echo "Enter commit message:" && read MSG部分

我很乐意在其中添加if else语句,这样我就能够经过aacv询问我是否要在完成后进行部署,若是我输入y则能够为我执行该操做,可是我想应该将其放入my .zshrc文件

相关文章
相关标签/搜索