What is a commit in Git?
A commit is a saved snapshot of changes to a project, with a short message saying what changed. Each one becomes a step in the project's history.
Last updated
In real life
Like a save point in a video game: you can always come back to it, and its label tells you where you were.
Try it yourself
The demo shows a working copy of a made-up bakery page. Make a change, like adding opening hours, and it waits as "not saved yet". Press Commit and it joins the history with a message describing the change.
Your working copy (branch: main)
This lessonRosa's Bakery
Order nowMake a change
History of the rosas-bakery repository (1 commit)
- a1f3c9 First version
Branches
A branch is a safe copy to try an idea on.
A commit saves a snapshot of your changes with a short message. Make a change, then commit it and watch it join the history.
Commit vs saving a file
Saving a file overwrites it with the newest version. A commit keeps a snapshot of every changed file, with a message, so earlier versions stay available.
Common questions
What makes a good commit message?
A short line saying what changed and why, like "Add opening hours to the home page". Your future self will thank you.
How often should I commit?
Whenever you finish a small, working step. Small commits make it easy to find and undo exactly the change that caused a problem.
Where you will use this
Quick check: Commit
Question 1 of 3