Skip to main content

Git Fundamentals: Guided Lab

Planning allowance: 2–3 hours including setup, state diagnostics and the Module 2 handoff. This is included in the module's 15–22 hours. Use a new disposable parent folder outside your curriculum or other real repositories. Run one block at a time and preserve predictions before reading calibration.

1. Initialize without changing global settings​

mkdir git-state-lab
cd git-state-lab
git init -b main
git config --local user.name 'Launchpad Learner'
git config --local user.email 'learner@example.invalid'
git config --local commit.gpgsign false
printf 'A\n' > state.txt
git add state.txt
git commit -m 'Record initial state'

If the folder already exists, choose a fresh empty parent. The fictional identity is for this local exercise. Disabling signing here is a repository-local accommodation for a disposable fixture; it does not change global signing or establish a real verified identity.

2. Predict the three versions​

printf 'B\n' > state.txt
git add state.txt
printf 'C\n' > state.txt
git status --short
git diff --staged
git diff
git show HEAD:state.txt
git show :state.txt
cat state.txt

Write what each inspection compares. Predict what the following commit saves, then execute it:

git commit -m 'Record staged version'
git show HEAD:state.txt
cat state.txt
git status --short
Reveal state calibration after your prediction

Before the commit: HEAD contains A, the index B, and the working file C. MM state.txt reports both staged and unstaged changes. Staged diff is A→B; unstaged diff is B→C. After the commit: HEAD and index contain B, the working file still C, and status reports M state.txt. This is expected, not lost work.

Finish this deliberate edit so later labs start clean:

git add state.txt
git commit -m 'Keep the final working version'

3. Track the Module 2 fixture​

Copy only your harmless practice-config.sh and its reconstruction checklist into a tooling subfolder of this repository. Use your file manager or commands you can explain. If the fixture was already completed elsewhere, preserve that evidence rather than claim a new independent attempt. If you skipped Module 2, complete its configuration exercise first.

Then create the exercise's ignore rule and disposable file:

printf 'scratch.tmp\n' > .gitignore
printf 'Disposable local scratch\n' > scratch.tmp
git add .gitignore tooling
git diff --staged
git commit -m 'Track reproducible tooling fixture'
git status --short
git check-ignore -v scratch.tmp
git ls-files tooling

Inspect every staged path before committing. scratch.tmp should be ignored; tooling files should be tracked. .gitignore does not stop tracking files already committed and cannot remove secrets from history. Use only the non-sensitive fixture. Describe that distinction; do not create a real secret to demonstrate it.

4. Undo a committed mistake with history preserved​

printf 'Restore checks content.\n' > policy.txt
git add policy.txt
git commit -m 'Document restore check'
printf 'Every backup guarantees recovery.\n' > policy.txt
git add policy.txt
git commit -m 'Introduce a deliberately false claim'
git revert --no-edit HEAD
cat policy.txt
git log --oneline -3

Expect the checked-content statement again, with the false-change commit still in history and a new revert commit after it. Revert is not deletion of the original commit. A clean patch does not prove semantic correctness: verify the file's intended claim.

Fresh transfer and acceptance​

On a new text file, repeat the three-state experiment with three different phrases and predict both diffs and committed contents before each observation. Revert a separate single-file committed mistake and explain why this preserves shared history. Preserve setup/version, states, ignore evidence, config handoff, corrected behavior and help used in the shared record.

Continue with the branching lab, then local collaboration. No Python application, hosted account or paid resource is required.