Exercises — Stage 1: First Save Point
Exercise 1: Run git status in different states
Goal: Build a reflex for using git status.
Steps:
- Run
git status. It says clean. - Open
index.htmland add a space somewhere. Save. - Run
git status. Now it saysindex.htmlis modified. - Undo the change and save again.
- Run
git status. It says clean once more.
What happened: git status compares your working folder against the most recent commit. When they match, it says clean. When they do not, it tells you exactly which files differ.
Exercise 2: Stage and unstage
Goal: See how git add moves a file into the staging area — and how to take it back out.
Steps:
- Change
<h1>Box Runner</h1>to<h1>Box Runner!</h1>and save. - Run
git status.index.htmlis modified but not staged. - Run
git add index.html. Rungit status— it is now staged. - Run
git restore --staged index.html. Rungit status— it is modified again, but not staged. - Undo your edit in the file and save to get back to clean.
What happened: git add moves changes into the staging area, and git restore --staged moves them back out. Your actual file is never touched by either command — only Git's "ready to save" box changes.
Exercise 3: Read your history
Goal: Get comfortable with git log.
Steps:
- Run
git log. - Run
git log --oneline. - Run
git log --oneline --decorate.
What happened: Each variation shows the same one commit in a different format. Later, when you have many commits, --oneline is the fastest way to see your whole history at a glance.
Exercise 4: Peek inside .git
Goal: Confirm that the Git repo is just files on disk.
Steps:
- Run
ls -ainsidebox-runner. You see.gitlisted. - Run
ls .git. You see folders likeobjects,refs, and a file calledHEAD. - Do not edit anything inside
.git.
What happened: The entire Git repository is a folder. That is why cloning a repo means copying files — there is no hidden database somewhere. If you deleted .git, you would go right back to Stage 0 (a plain folder with no history).