git commit Save staged changes as a snapshot in history

Records everything in the staging area as a new commit, with your message, name and the time. A commit is a permanent checkpoint you can return to or share.

Synopsis

git commit [OPTION]...

Common options

Option or formWhat it does
-m MESSAGEUse this message instead of opening an editor
-aAutomatically stage every tracked file that changed before committing
--amendReplace the last commit with a new one, to fix its message or add a forgotten file
--no-editWith --amend, keep the existing message
-vShow the diff in the editor while you write the message
--allow-emptyMake a commit even when nothing changed

Examples

Commit what is staged
git commit -m "Add contact form"
[main 3f2a9c1] Add contact form
 2 files changed, 41 insertions(+)
Stage tracked changes and commit in one step
git commit -am "Fix typo in header"
Fix the message of the last commit
git commit --amend -m "Add contact form with validation"
Add a forgotten file to the last commit
git add forgot.txt && git commit --amend --no-edit
Write a long message in your editor
git commit

Notes

See also

Last reviewed 2026-10-09.