Your First Commit
Git commit -m.
This is the big moment. Your first commit. A commit is a snapshot of everything you staged, with a short message saying what you did.

- Your first snapshot
- Everything you staged
- Plus a short message
git commit
We type git commit, dash m, and a message in quotes. Dash m stands for message. Git prints a summary. Main, root commit, which means the very first one. Then a short code, which is this commit's ID. Then our message, and one file changed. Let's check status. Working tree clean. Everything is saved.
git commit -m "Add home page" [main (root-commit) f7d9757] Add home page 1 file changed, 1 insertion(+) create mode 100644 index.html git status On branch main nothing to commit, working tree clean
One more time
Let's do the whole cycle again. We add a second line to the page. The double arrow adds to the end of the file, instead of replacing it. Status shows the file is modified. Add it. Commit it, with a new message. Two commits, two snapshots in our history.
echo "<p>Welcome!</p>" >> index.html git status On branch main Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git restore <file>..." to discard changes in working directory) modified: index.html no changes added to commit (use "git add" and/or "git commit -a") git add index.html git commit -m "Add welcome text" [main d6752ba] Add welcome text 1 file changed, 1 insertion(+)
Summary
Edit, add, commit. That's the heartbeat of Git, and you'll repeat it every day. Next, a clear picture of where your changes live.
Key takeaways- git commit -m "message"
- Edit, add, commit
- Working tree clean = all saved