Git add and commit in one command

git commit -am "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 applies. The above commands 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.


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'

EDIT: Reverted back to ticks ('), as otherwise it will fail for shell expansion on Linux. On Windows, one should use double-quotes (") instead (pointed out in the comments, did not verify).

Tags:

Git