git add -A, git commit in one command?

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, and if Git had an option like git commit -Am "commit message", it would make life that much more convenient.

  • Syncing code across multiple computers, with minimum effort
  • Merged changes are not updated in local branch push to remote repository
  • Cleaning up after a conflicted git merge?
  • How to get --detect-branches to work with git-p4?
  • git rebase causes feature branch to lose tracking information
  • Pushing to github after a shallow clone
  • git commit has the -a modifier, but it doesn’t quite do the same as doing git add -A before committing. git add -A adds newly created files, but git commit -am does not. What does?

  • Git clone of OpenShift repository hangs in linux, but not windows
  • What's the easiest way to deploy a folder to a branch in git?
  • Convention for storing bare Git repositories in home directory?
  • How to add eclipse project to existing git repo?
  • Bitbucket git credentials if signed up with Google
  • Download or clone only a branch in git and not the entire tree
  • 15 Solutions collect form web for “git add -A, git commit in one command?”

    You can use git aliases, e.g.

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

    and use it with

    git add-commit -m 'My commit message'
    
    git commit -a -m "message"
    

    is an easy way to tell git to delete files you have deleted, but I generally don’t recommend such catch-all workflows. git commits should in best practice be fairly atomic and only affect a few files.

    git add .
    git commit -m "message"
    

    is an easy way to add all files new or modified. also, the catch-all qualification above applies. will not delete files deleted without the git rm command.

    git add app
    git commit -m "message"
    

    is an easy way to add all files to the index from a single dir, in this case the app dir.

    To keep it in one line use:

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

    This line will add and commit all changed and added files to repository.

    Just combine your commands:

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

    In the later version of git you can add and commit like this

    git commit -a -m "commit message"
    

    Additionally you an alias:

    [alias]
        ac = commit -a -m
    

    Then you can use it like this:

    git ac "commit message"
    

    On my windows machine I have set up this .bashrc alias to make the entire process more simple.

    • create / locate your .bashrc – refer SO thread
    • add the following line to file

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

      it does git add commit and push . tweak it in any manner, say you don’t want the push command remove that part

    • reload .bashrc / close and reopen your shell

    • now you can do the entire process with gacp command .

    I do a shell

    #!/bin/sh
    
    clear
    
    git add -A 
    git commit -a -m "'$*'"
    

    save for example git.sh and later call:

    sh git.sh your commit message
    

    If you type:

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

    once, you will just need to type

    git a
    

    every time:

    git a 'your comment'
    

    I use the following (both are work in progress, so I’ll try to remember to update this):

    # 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
    

    With the echo "Enter commit message:" && read MSG part inspired by Sojan V Jose

    I’d love to get an if else statement in there so I can get aacv to ask me if I want to deploy when it’s done and do that for me if I type ‘y’, but I guess I should put that in my .zshrc file

    I use the following alias for add all and commit:

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

    Then, by typing:

    git ac
    

    I get a vim window to get more editing tools for my commit message.

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

    I use this git alias:

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

    So, instead of call

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

    I just do:

    git cam "this is a great commit"

    you can use
    git commit -am “[comment]” // best solution
    or
    git add . && git commit -m “[comment]”

    pretty sure you can use:

    git commit -am "commit all the things"
    

    To keep it in one line use:

    gacm "your comment"
    
    Git Baby is a git and github fan, let's start git clone.