Git add and commit in one command

后端 未结 27 2422
旧巷少年郎
旧巷少年郎 2020-11-28 00:28

Is there any way I can do

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

in one command?

I seem to be doing those two commands a lot,

27条回答
  •  青春惊慌失措
    2020-11-28 00:51

    I have this function in my .bash_profile or .profile or .zprofile or whatever gets sourced in login shells:

    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"
    }
    

提交回复
热议问题