Supplement · Git Engineering · 05-04-thuc-hanh

Thực hành quan sát Git thay vì học thuộc lệnh

Mỗi script tự tạo thư mục tạm, assert kết quả và cleanup; không sửa repository đang học.

Yêu cầu: Git ≥ 2.25, Bash, mktemp, awk, grep. Chạy: bash labs/run-all.sh. Trên Windows dùng Git Bash.

01 · Objects, refs và reflog

labs/01-objects-refs-reflog.sh chứng minh hai path cùng content dùng một blob và commit bị reset còn tìm được trong reflog.

02 · Index conflict stages

labs/02-index-conflict.sh tạo conflict thật, kiểm stages 1/2/3 rồi resolve về stage 0.

03 · Pack và GC

labs/03-pack-gc.sh tạo loose objects, chạy GC, kiểm pack count và fsck.

04 · Transfer trace

labs/04-transfer-trace.sh tạo bare remote local, push/clone qua file smart transport và kiểm packet trace. Dữ liệu lab không chứa credential.

05 · Shallow và sparse

labs/05-shallow-sparse.sh kiểm shallow history chỉ có một commit và sparse checkout chỉ materialize directory đã chọn.

06 · Multiple worktrees

labs/06-worktree.sh chứng minh worktree có state riêng nhưng chia sẻ common repository.

07 · Bundle recovery

labs/07-recovery-bundle.sh tạo/verify bundle, restore clone, so commit ID và chạy integrity check.

Quan sát thêm

Sau mỗi lab, bỏ tạm phần cleanup nếu muốn inspect cat-file, ls-files --stage, verify-pack hoặc Trace2. Không làm vậy trên repo thật; copy fixture sang sandbox riêng.

← Câu hỏiChecklist →

Lab evidence & verification record

Nội dung evidence từ source Markdown được merge vào canonical lab page để không tạo standalone lesson Markdown.

# Git curriculum executable evidence

## Environment

- Executed 2026-08-23 on Windows with Git for Windows 2.47.0 and bundled Bash.
- Required for rerun: Git >= 2.25 and a Bash environment with `mktemp`, `awk`, `grep`.
- Command: `bash labs/run-all.sh` from `study-guide/supplements/git/`.
- Scripts use only temporary repositories and remove them on exit.

## Execution record

| Lab | Assertion | Status |
|---|---|---|
| 01 objects/refs/reflog | Equal content has equal blob ID; reset commit appears in reflog | PASS |
| 02 index conflict | Unmerged index exposes stages 1/2/3; add resolves to stage 0 | PASS |
| 03 pack/GC | 90 loose objects became 1 pack and `git fsck` passed | PASS |
| 04 transfer trace | Local smart transfer succeeded and emitted packet trace | PASS |
| 05 shallow/sparse | Depth was one; only selected directory was materialized | PASS |
| 06 worktree | Per-worktree git dir differed from shared common dir | PASS |
| 07 bundle recovery | Bundle verified, restored the same commit, and passed fsck | PASS |

All seven scripts completed with exit code 0 via `bash labs/run-all.sh`. The output contained expected Git for Windows LF/CRLF warnings; assertions were unaffected. Git LFS, signing, server hooks and network protocol v2 are documented but intentionally not claimed as executed because they require optional software, keys or a server fixture.