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.

[alias]
        ac = !git add -A && git commit

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

git config --global alias.ac '!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 vogella.com. 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

Comments are closed.