What Is a Git Commit?
A commit is a saved snapshot of your project at a point in time, with a message, an author, and a unique identifier that links it to its parent.
A commit is the fundamental unit of history in Git. Every time you commit, you record the current state of the tracked files along with who you are, when you saved it, and a short message explaining the change. Commits chain together to form the history that CI/CD pipelines build and deploy from.
What a commit records
A commit captures a snapshot of the tracked files, a reference to one or more parent commits, the author and committer, timestamps, and a message. Together these answer what changed, when, by whom, and why. The "why" lives in the message, which is the part future readers and reviewers rely on most.
Creating a commit
You first stage the changes you want to include, then commit them. A clear message in the imperative mood keeps history readable.
git add src/auth.ts
git commit -m "Reject expired session tokens"Commits form a chain
Each commit points back to its parent, forming a directed history. Branches are just movable pointers into this chain, and merges create commits with more than one parent. Walking the parents lets Git reconstruct any past state of the project exactly.
Why commits matter for CI/CD
A pipeline run is tied to a single commit. When CI reports a green or red check, it is reporting on that exact snapshot, so the result is reproducible: anyone can check out the same commit and get the same build. Small, focused commits also make it far easier to bisect history and find the change that introduced a failure.
Habits of good commits
- Keep each commit focused on one logical change.
- Write a message that explains the why, not just the what.
- Commit working code so each point in history is buildable.
- Avoid bundling unrelated edits, which makes review and bisection harder.
Key takeaways
- A commit is a snapshot with a message, author, and unique hash.
- Commits chain to their parents to form the full project history.
- CI runs against a specific commit, making build results reproducible.