At the end of the last lesson, your practice folder became a repository with an empty history, and git status listed prices.js and notes.txt as untracked. With two small files, the next step looks like saving both of them in a first commit. Git even has a command named after it, so how hard can it be?
In this lesson, you’ll make that first commit and find out exactly what Git saved and what it left out. You’ll learn where Git keeps a change before it becomes part of the history, and you’ll be able to read git status, in its long and short forms, and say for each file whether it’s untracked, modified, or staged. Start by giving git commit a try.
Make Your First Commit
A commit is one saved version of your project in the repository’s history, and Git makes one when you run git commit. Every commit needs a short message that says what it changes, and the -m option lets you type that message right in the command. Open a terminal in your grocery-practice folder and try it:
$ git commit -m "Add the practice price list"
On branch main
Initial commit
Untracked files:
(use "git add <file>..." to include in what will be committed)
notes.txt
prices.js
nothing added to commit but untracked files present (use "git add" to track)
Okay, it looks like Git didn’t make a commit. Take a look at the last line because it tells you why. Git sees your two files, but you haven’t added anything to the commit, and Git won’t guess which files you mean. The hint in parentheses says how to choose one with git add and a filename.
The price list is the file this commit is about, so add prices.js and run the same commit command again:
$ git add prices.js
$ git commit -m "Add the practice price list"
[main (root-commit) 643a1ad] Add the practice price list
1 file changed, 7 insertions(+)
create mode 100644 prices.js
And… there’s your first commit! The first line shows the branch, main, and root-commit means this commit is the first one in the history. The 643a1ad is a short ID for the commit, and yours will be different. Your message comes after it, and the lines below it sum up what the commit changed.
Your practice folder holds two files, and the commit went through without a complaint. Read the output once more and decide on an answer before you open the box. Is notes.txt in this commit too?
No, it isn’t. The second line of the output says 1 file changed, with seven new lines, which is all of prices.js. To check, ask Git for the status of your folder:
$ git status
On branch main
Untracked files:
(use "git add <file>..." to include in what will be committed)
notes.txt
nothing added to commit but untracked files present (use "git add" to track)
The notes file is still untracked. To see what the commit itself holds, run git show --stat, which shows the latest commit and a list of the files it changed:
$ git show --stat
commit 643a1ad4de3c70e043fbdab4bea64e9f90c18d04
Author: Martin Breuss <[email protected]>
Date: Mon Nov 23 13:03:30 2026 +0000
Add the practice price list
prices.js | 7 +++++++
1 file changed, 7 insertions(+)
The commit lists prices.js and no other file, so notes.txt isn’t in it. Git has no copy of it anywhere, in this commit or in the .git folder. If you deleted notes.txt now, Git couldn’t bring it back.
If you expected the commit to hold both files, you’re in good company. Most people new to Git picture a commit as a snapshot of the whole project folder, and it’s a very reasonable guess for a command that saves your work. That’s why you’re trying it in a practice folder, where finding out doesn’t cost you anything.
Git builds each commit only from the files you added. You added prices.js, so that’s what the commit took, and notes.txt stayed in your folder as an untracked file that Git has never saved. So run git status before every commit, and check that every file you mean to save is ready to go in.