Objective: gain fluency with Git workflows used in collaborative HPC projects. Produce a short lab log (codes/lab03/lab-notebook.md) containing command transcripts (script logs or git status snapshots), screenshots when useful, and short reflections on pitfalls. Use a single repository under codes/lab03/ unless noted; keep commits clean and chronologically meaningful.
Exercise 1 — Repository bootstrap & hygiene¶
Initialize a repository in
codes/lab03/and add a starterREADME.mddescribing the experiment plus asrc/directory with a minimal program or script (any language).Create
.gitignoreentries for build artifacts, editor configs, and datasets you expect to generate. Document why each pattern belongs there.Configure local Git settings (
user.name,user.email,core.editor,init.defaultBranch) and capture the output ofgit config --list --local.Make at least two initial commits: one for the scaffold, one for the ignore/configuration setup. Include commit messages that match the lecture guidance (50-char subject, descriptive body). Paste
git log --onelineinto the notebook.
Exercise 2 — Intentional branching & merging¶
Create
feature/parserandfeature/reportbranches frommain. On each branch implement a focused change (e.g., parser adds CLI flags, report adds Markdown summary). Ensure each branch contains 2+ commits.Before merging, run
git fetch --alland inspect divergence withgit log --graph --oneline --decorate --all. Embed a screenshot or copy of the graph.Merge
feature/parserintomainwith a fast-forward. Then intentionally divergemainandfeature/reportso the merge requires a merge commit (e.g., edit the same paragraph in different ways). Resolve the conflict, documenting the decision process and the final merged diff.Tag the resulting state as
v0.1-gitlabsand push the tag to a remote (usegit remote add origin <path>to another folder if GitHub is unavailable). Verify withgit tag -nandgit push --tagsoutput.
Exercise 3 — History inspection & rollback practice¶
Use
git blame,git show, andgit diff main..feature/parserto answer specific questions: who added the CLI flag, which commit changed the README introduction, and what files differ between branches. Copy the commands + condensed outputs.Demonstrate three undo strategies on throwaway commits:
git restore <file>(working tree only),git reset --soft HEAD~1(rewrite staging), andgit revert <hash>(create corrective commit). Explain when each is safe on shared branches.Simulate a mishap: create a commit with an undesirable binary file, then remove it properly using
git rm --cached+.gitignore. Show that history no longer includes the blob by runninggit cat-file -s <hash>before/after.Bundle the repository (
git bundle create lab03.bundle main feature/report) or export a patch series (git format-patch main~3..main) and note how teammates could review or apply it offline.
Submission checklist¶
Lab notebook with commands, commentary, and screenshots.
Repository archive (
lab03.bundleor.zip) plus tagv0.1-gitlabs.Mention open questions (e.g., how to split commits better, CLI flags you’d like to automate) for discussion in Lecture 4.