Basics: from file to commit · Lesson 2 of 15
From working tree to commit
Understand the three areas and use status, add and commit confidently.
Git separates work into three areas. The working tree holds files you edit. The staging area is the exact proposal for the next commit. The repository stores snapshots. You can edit five files but create a focused commit from only two.
Working tree
git add
Staging area
git commit
Repository
git init -q -b main echo "v1" > app.txt git status -s git add app.txt git status -s git commit -q -m "Add app file" git log --format=%s
In status -s, the first column describes staging and the second the working tree. ?? is untracked, A is staged, and M is modified but unstaged. A commit is a snapshot, not a file-save operation.
What's the output?
git init -q -b main echo "one" > a.txt git add a.txt git commit -q -m "First" echo "two" >> a.txt git status -s
What will this code print?
Exercise
Create note.txt containing learn, add it, make a quiet commit named Add note, and print its subject.
Expected output: Add note
git init -q -b main echo "learn" > note.txt git log --format=%s
Learn more from
Played 0 of 2 games
Sign in to save your progress and earn XP.