A commit is one saved checkpoint in a project's history. When a developer finishes a meaningful change, such as fixing a broken link or adding a booking form, they commit it: the files at that moment are recorded along with a short note explaining why. Later, anyone can look back at that exact commit, compare it with others, or reverse it.
What a commit contains
In Git, every commit stores:
- A snapshot of the tracked files as they were at that moment.
- The author's name and email, plus a timestamp.
- A message written by the author.
- A pointer to its parent commit (or two parents, if it merged two branches).
- An ID, the hash, such as
9f3c2a1in its shortened form, calculated from all of the above.
Because the hash depends on the parent, changing an old commit changes every hash after it. That is what makes the history trustworthy.
How a commit is made
Git uses a two-step process. First you stage the changes you want with git add, which lets you choose some edits and leave others for later. Then git commit -m "Fix footer phone number" records them. A commit only exists on your machine until you push it to a shared repository such as one on GitHub.
Using commit history to undo one mistake
A plumber's site starts showing the wrong opening hours. The developer runs git log and sees a commit from Monday titled "Update contact page layout". Opening it shows that the hours text was accidentally deleted along with the layout change. Running git revert on that commit creates a new commit that undoes it, without touching anything done since. The fix takes minutes because the change was isolated and clearly labelled.
Why commits matter to a site owner
You will probably never write one, but a developer's commit history is a readable log of what was done to your site and when. It can settle questions like "when did the contact form stop working?" and shows how much real work went into an invoice. If you want changes reviewed before they go live, commits are usually grouped into a pull request.
Commit habits that cause trouble
- Giant commits. Mixing a redesign, a bug fix and a dependency upgrade in one commit makes it impossible to undo just one of them.
- Messages that say nothing. "WIP" or "changes" helps no one. Say what changed and why.
- Committing generated or secret files. Build output,
node_modulesand.envfiles belong in.gitignore. - Amending commits that were already pushed. It rewrites shared history and confuses everyone who pulled the old version.
Related terms
- Git: the tool that creates and stores commits.
- Repository: where the chain of commits lives.
- Pull request: a bundle of commits proposed for review.
- Version control: the general practice commits belong to.