# Commit

URL: https://softwaredictionary.org/terms/commit
Category: Version Control
Last updated: 2026-09-29

In short: A commit is a saved snapshot of a project's files in Git, recorded with a unique ID, an author, a timestamp, and a message describing what changed.

## What is a commit in Git?

A commit records the state of your project at a specific moment. Each commit stores a snapshot of the tracked files, who made it, when it was made, a message explaining the change, and a link to the commit or commits that came before it. Chained together through those links, commits form the project's history.

Before committing, you choose which changes to include by adding them to the staging area with `git add`. Running `git commit` then saves exactly those staged changes. Every commit gets a unique identifier called a hash, a long string of letters and digits, which you can use to view, compare, or revert that exact version.

Commits work like save points in a document's history, each with a short note explaining what was done. Good commits are small and focused on one logical change, with a clear message like 'Fix login redirect loop' rather than 'updates'. This makes the history easy to read, review, and undo.

Committing is not the same as sharing. A commit exists only in your local repository until you run `git push` to send it to a remote repository. The word commit is also used in databases, where it means making a transaction's changes permanent.

## Key takeaways

- A commit is a snapshot of staged changes plus metadata: author, date, message, and parent.
- Each commit has a unique hash that identifies it.
- Commits stay local until you push them to a remote repository.
- Small, focused commits with clear messages make history easy to understand.

## Example: Creating and inspecting commits

```bash
# See what has changed
git status

# Stage a specific file for the next commit
git add src/login.ts

# Save the staged changes with a descriptive message
git commit -m "Fix login redirect loop"

# View the three most recent commits (short hash and message)
git log --oneline -3

# Reword the last commit's message (only before pushing)
git commit --amend -m "Fix redirect loop after login"
```

## Frequently asked questions

**How do I undo a commit in Git?**

To undo a commit that has already been shared, use `git revert <hash>`, which creates a new commit that reverses it. To undo your most recent local commit while keeping its changes in your files, use `git reset --soft HEAD~1`.

**What makes a good commit message?**

A good commit message starts with a short summary line, around 50 characters, written as a command, such as 'Add password reset email'. If more context is needed, add a blank line followed by a longer explanation of why the change was made.

**What is the difference between git commit and git push?**

`git commit` saves a snapshot in your local repository. `git push` uploads your local commits to a remote repository so others can see them.

## Sources

- [Git documentation: git-commit](https://git-scm.com/docs/git-commit)

---

Software Dictionary: https://softwaredictionary.org/ · https://softwaredictionary.org/llms.txt
