Git Alias – git add -A and git commit in one command

In in 95% of my time I type “git add . -A” directly followed by “git commit -m “message” in the Git version control system.

That is a lot of typing for a very common case. Fortunately git allows to add an alias for the command. To add an alias for git add and git commit to your git configuration, open your .git/config file and add the following.

        ac = !git add -A && git commit

Alternative you can use the –global flag from the command line:

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

You now can add and commit to your Git repository via the command:

git ac -m "message"

Unfortunately alias seems not to be supported on the window implementation of git (msysgit). See the bug report: msysgit does not support alias definition.

I hope this helps. More details can be found in my Git Tutorial. You may want to follow me on Twitter.

About Lars Vogel

Lars Vogel is the founder and CEO of the vogella GmbH and works as Eclipse and Android consultant, trainer and book author. He is a regular speaker at international conferences, He is the primary author of With more than one million visitors per month this website is one of the central sources for Java, Eclipse and Android programming information.
This entry was posted in Eclipse and tagged . Bookmark the permalink.

5 Responses to Git Alias – git add -A and git commit in one command

  1. Mike Lehmann says:

    Why not use a decent Git GUI like smartGit? Often one is not just working on one feature, but also fixes one or another minor bug. With smartGit you can stage individual pieces of code to be able to create clear-cut commits. IIRC, this is not possible with plain command line Git and saved my ass a lot of times. Give it a try and you never will use command line again for such common tasks.

  2. Lars Vogel says:

    @Mike: Thanks for the tip. Addon tools are nice but I like to get the command lineright too. It seems that the command line works always the best on all platforms.

  3. Randy says:

    Why not just use `git commit -a`?

  4. admin says:

    @Randy: That would not include new files, see

  5. Shamsul Maruf says:

    If you are in linux you can use ” git add . ; git commit — …” .

Comments are closed.