Skip to main content
What is a commit? In Git, saving files isn’t just a simple “save” — you create a commit. A commit records a permanent snapshot of your project at a specific moment in time. It captures the exact state of tracked files so you can inspect, compare, or revert changes later.
The image features two panels illustrating the concept of a Git commit. The left panel shows buttons labeled "Save" and "Commit," while the right panel depicts a camera icon with text explaining a commit as a "permanent snapshot of your work at a specific moment."
How commits work — quick overview
  • You stage changes you want to include in the next snapshot.
  • You create a commit with a short, descriptive message that explains the reason for the change.
  • The commit records the staged content and stores metadata such as author, timestamp, message, and a unique identifier (SHA).
  • The repository history becomes a sequence of commits (snapshots) that can be reviewed or restored.
Staging and creating commits Before a commit, changes must be staged. Typical commands:
If you only modified files that are already tracked by Git, you can stage and commit in one step using -a:
Best practices for commit messages
Write concise, meaningful commit messages that explain the why, not just the what. For new files, remember to stage them with git add before committing. Use the imperative tense for messages (e.g., “Fix bug in parser” instead of “Fixed bug in parser”).
Commit metadata — what Git stores Inspect recent commits Use git log to review history. For a compact view:
Example output:
Why commits matter Because each commit is a snapshot, your team can see how the project evolved, identify when and why a change happened, and revert to a known-good state when mistakes occur. Commits form the backbone of version control workflows like feature branching, code review, and continuous integration. Further reading and references

Watch Video