How to Commit in Git (with git commit)
A commit saves a snapshot of your staged changes to the local Git repository. Note two important things: first, you must explicitly stage changes with git add before committing — modified files are not included automatically. Second, a commit only saves to the local repository; you need git push to share it with a remote.
The Git Cheat Sheet
No need to remember all those commands and parameters: get our popular "Git Cheat Sheet" - for free!
Basic Commit
Stage the files you want to include, then commit with a message:
$ git add index.html css/styles.css
$ git commit -m "Change titles and styling on homepage"
Commit All Changed Files
To include all currently changed tracked files without a separate git add step, use -a. Note that new untracked files are still not included:
$ git commit -a -m "Change titles and styling on homepage"
Amending the Last Commit
Use --amend to fix a mistake in the most recent commit — either the message, the staged content, or both. Git rewrites the last commit with the new changes:
$ git add forgotten-change.js
$ git commit --amend -m "New commit message"
Only amend commits that have not been pushed to a remote yet. Rewriting published commits causes problems for anyone who has already pulled them.
No Command Line Needed
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. You can even add individual chunks and lines from a file instead of the whole file!
Download the Cheat SheetFree
Get 18 of our most popular Cheat Sheets in one handy ZIP!

Thanks! Please Check Your Inbox!
Want to win one of our awesome Tower shirts?
Tell your friends about the package!
