Using -a with git commit

The -a option in the git commit command is the shortcut that stands for “all”. When you use git commit -a, it tells Git to automatically stage (add) and commit all changes to tracked files in your repository.

In simpler terms, normally, you need to explicitly tell Git which changes you want to include in the next commit by using the git add command. However, when you use git commit -a, Git skips the git add step for files that are already being tracked and goes straight to committing all changes in those files.

It’s important to note that the -a flag won’t include changes in untracked files. You still need to use git add for new files before committing them.

Here’s an example:

# Stage changes in tracked files
git commit -a -m "Commit message"

This command stages and commits changes in all tracked files, saving you the step of explicitly using git add for each file.