git commit

The "commit" command is used to save your changes to the local repository.

Note that you have to explicitly tell Git which changes you want to include in a commit before running the "git commit" command. This means that a file won't be automatically included in the next commit just because it was changed. Instead, you need to use the "git add" command to mark the desired changes for inclusion.

Also note that in Git (not like in Subversion), a commit is not automatically transferred to the remote server. Using the "git commit" command only saves a new commit object in the local Git repository. Exchanging commits has to be performed manually and explicitly (with the "git fetch", "git pull", and "git push" commands).

Important Options

-m <message>

Sets the commit's message. Make sure to provide a concise description that helps your teammates (and yourself) understand what happened.


Includes all currently changed files in this commit. Keep in mind, however, that untracked (new) files are not included.


Rewrites the very last commit with any currently staged changes and/or a new commit message. Git will rewrite the last commit and effectively replace it with the amended one. Note that such a rewriting of commits should only be performed on commits that have not been pushed to a remote repository, yet.

The Git Cheat Sheet

No need to remember all those commands and parameters: get our popular "Git Cheat Sheet" - for free!

Usage Examples

For a basic workflow, you can use the "git add" command to stage changes for the next commit. The actual commit command will then wrap up the mentioned changes in a new commit object:

git add index.html css/styles.css
git commit -m "Change titles and styling on homepage"

If you have lots of changed files in your working copy - and want all of them included in the next commit - you can make use of the "-a" parameter and thereby omit the "git add" step:

git commit -a -m "Change titles and styling on homepage"

The "--amend" option comes in handy, for example, when you mistyped the last commit's message or forgot to add a change. The following example will correct the very last commit by overwriting its message and adding another change:

git add forgotten-change.js
git commit --amend -m "New commit message"


Easy Committing in Tower

In case you are using the Tower Git client, committing is very easy: just check the changed files you want to include and enter your commit message.

Even --amend is available as a simple checkbox option!

Learn More

Get our popular Git Cheat Sheet for free!

About Us

As the makers of Tower, the best Git client for Mac and Windows, we help over 100,000 users in companies like Apple, Google, Amazon, Twitter, and Ebay get the most out of Git.

Just like with Tower, our mission with this platform is to help people become better professionals.

That's why we provide our guides, videos, and cheat sheets (about version control with Git and lots of other topics) for free.