Git add -A and git commit one liner

When working with Git, I often find myself typing:


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

This stages any changes including new files (which "git commit -am" doesn’t), marks any files that have been deleted from the working copy as removed and commits to the repository.

Following a quick Google search, and thanks to this handy git alias article, I created a “ca” (commit all) alias using:


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

Now committing all changes is as simple as:


git ca -m "My commit message"

This is a good solution, however I prefer adding the following function to my ~/.profile file:


function gca {
  git add -A && git commit -m "$1"
}

Which gets us to:


gca "My commit message"

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>