Ad space (banner)
🌿Git Lessons
Lesson 57 / 59

Mastering the git commit -am Shorthand

This lesson is for anyone who wants to combine add and commit into a single command, using git commit -am "Batched fix". git commit -am is a shorthand that stages already-tracked file changes and commits them at the same time.

Use it in the form git commit -am "message". -a automatically stages all changes to already-tracked files, and -m specifies the commit message.

Running git commit -am "Batched fix" stages every changed, already-tracked file and commits them right then and there, saving you the step of writing git add -A && git commit -m "..." separately.

A common early mistake is expecting -a to also pick up brand-new, untracked files — it doesn't; a newly created file still needs a separate git add.

In real practice, this gets used a lot for committing a small fix quickly. That said, it makes it easy to commit changes across several files without reviewing them individually, so for changes that need review, sticking to the regular add-then-commit flow is a better fit.

Git
Try it (type this into the pseudo terminal)
git commit -am "Batched fix"

🧑‍💻 You can type this command into the Git pseudo terminal to try it yourself (this page itself has no interactive terminal).

Ad space (banner)
Ad space (in-article)