[{"id":"gitintermediate-001","courseId":"git-intermediate","domain":"repository-basics","topic":"Staging part of a file with add -p","prompt":"You edited two separate places in lib/simplegit.rb but want the next commit to contain only one of them. Which command lets you stage one block of changes and leave the other unstaged?","hint":"Look for a mode that asks about each block of changes separately.","explain":"Git can stage part of a file, not only the whole file. Changes are shown as hunks, and you decide for each hunk whether it enters the staging area before you commit.","source":"https://git-scm.com/book/en/v2/Git-Tools-Interactive-Staging","interaction":{"type":"single"},"options":[{"id":"a","text":"git add -p","why":"The patch mode shows each hunk and asks whether to stage it, so you can stage one block and leave the other unstaged."},{"id":"b","text":"git add -A","whyNot":"It stages all changes at once with no per-hunk choice, so both blocks would be staged."},{"id":"c","text":"git commit -a","whyNot":"It stages all modified tracked files as whole files and commits them; it does not let you skip a hunk."},{"id":"d","text":"git checkout -p","whyNot":"checkout --patch restores or discards parts of files in the working tree; it does not stage them."}],"answer":"a","explanation":"git add -p (--patch) goes through each hunk of the diff and lets you stage or skip it, so one file can be partly staged.","concept":"git add -p (--patch) goes through each hunk of the diff and lets you stage or skip it, so one file can be partly staged.","rev":1,"updatedAt":"2026-10-23","kind":"scenario","takeaways":["Use git add -p to stage a file one hunk at a time.","A partly staged file shows both staged and unstaged lines in git status."]},{"id":"gitintermediate-002","courseId":"git-intermediate","domain":"repository-basics","topic":"Diffing staged changes","prompt":"In a repository where some edits are already staged, running `git diff` with no arguments shows the changes you have staged for the next commit.","hint":"Ask which two places the plain diff compares by default.","explain":"git diff compares two sides, and the choice of sides decides whether you see unstaged edits or edits already in the staging area. Each form of the command names its two sides.","source":"https://git-scm.com/docs/git-diff","interaction":{"type":"true-false"},"options":[{"id":"a","text":"True","whyNot":"Plain git diff compares the working tree with the index, so it shows unstaged changes, not staged ones."},{"id":"b","text":"False","why":"Staged changes are shown with git diff --cached (or --staged), which compares the index with HEAD."}],"answer":"b","explanation":"git diff with no commit compares the working tree with the index; git diff --cached compares the index with HEAD, the last commit.","concept":"git diff with no commit compares the working tree with the index; git diff --cached compares the index with HEAD, the last commit.","rev":1,"updatedAt":"2026-10-23","kind":"scenario","code":"git diff\ngit diff --cached","takeaways":["Plain git diff shows unstaged changes; add --cached to see what is staged."]},{"id":"gitintermediate-003","courseId":"git-intermediate","domain":"repository-basics","topic":"Listing tracked files with ls-files","prompt":"A tracked file was deleted from the working tree with rm, and the deletion is not staged. Which TWO flags make git ls-files report that file as having an unstaged change?","hint":"Think about which flags compare the working tree against the index.","explain":"ls-files compares the index with the working tree and reports differences in several categories. Each flag picks one category, and some categories overlap with others.","source":"https://git-scm.com/docs/git-ls-files","interaction":{"type":"multiple","tellCount":true},"options":[{"id":"a","text":"-d (--deleted)","why":"It shows files with an unstaged deletion, which is exactly this case."},{"id":"b","text":"-m (--modified)","why":"It shows files with an unstaged modification, and the docs count an unstaged deletion as one too."},{"id":"c","text":"-o (--others)","whyNot":"It lists untracked files, which are not in the index, so a tracked file never appears there."},{"id":"d","text":"--resolve-undo","whyNot":"It shows only files with resolve-undo data left by an earlier conflict resolution, not deleted files."},{"id":"e","text":"-u (--unmerged)","whyNot":"It shows only unmerged entries left by a conflict, not deleted files."},{"id":"f","text":"-k (--killed)","whyNot":"It shows untracked files that block tracked files from being checked out, so a deleted tracked file never appears."}],"answer":"ab","explanation":"ls-files -d lists files with an unstaged deletion, and -m lists unstaged modifications, which also include unstaged deletions.","concept":"ls-files -d lists files with an unstaged deletion, and -m lists unstaged modifications, which also include unstaged deletions.","rev":1,"updatedAt":"2026-10-23","kind":"scenario","takeaways":["ls-files -m also reports files you deleted without staging the deletion.","ls-files -o lists untracked files, never tracked ones."]},{"id":"gitintermediate-004","courseId":"git-intermediate","domain":"repository-basics","topic":"Rename detection in diffs","prompt":"A teammate sets diff.renames to false. They move a file to a new path with no content change, stage both sides with git add -A, and run git diff --cached. What does the diff show?","hint":"Consider what the setting does to pairing removed files with added files.","explain":"Git can pair a removed file with an added file that has the same content and report one rename. A configuration setting controls whether that pairing happens at all.","source":"https://git-scm.com/docs/git-diff","interaction":{"type":"single"},"options":[{"id":"a","text":"A deleted file for the old path and a new file for the new path","why":"With rename detection off, Git no longer pairs the two sides, so it reports a deletion and an addition."},{"id":"b","text":"A single rename line from the old path to the new path","whyNot":"That is the default behaviour; the setting turns it off, so no rename is reported."},{"id":"c","text":"Nothing, because identical content in two paths produces no diff","whyNot":"The path change itself is a change, so Git still reports it."},{"id":"d","text":"A copy at the new path, with the old path left unchanged","whyNot":"Copy detection needs diff.renames set to copies, and it is not on here."}],"answer":"a","explanation":"With diff.renames set to false, rename detection is disabled, so a moved file shows as a deletion plus an addition.","concept":"With diff.renames set to false, rename detection is disabled, so a moved file shows as a deletion plus an addition.","rev":1,"updatedAt":"2026-10-23","kind":"scenario","takeaways":["diff.renames decides whether deleted and added files are paired as renames.","Setting diff.renames to copies also detects copies."]},{"id":"gitintermediate-005","courseId":"git-intermediate","domain":"repository-basics","topic":"Selecting log commits by ref decoration","prompt":"You want git log to focus on the commits that some branch or tag refers to, rather than the full history. Which option does this?","hint":"Think about selecting commits by the names that point at them.","explain":"History simplification decides which commits git log keeps. Some options select commits by path, some by the names that point at them, and some only change how the graph is pruned.","source":"https://git-scm.com/docs/git-log","interaction":{"type":"single"},"options":[{"id":"a","text":"--simplify-by-decoration","why":"It selects the commits that some branch or tag refers to; git may keep a few extra commits so the history still makes sense."},{"id":"b","text":"--boundary","whyNot":"It outputs the excluded boundary commits, marked with a minus sign; it does not hide commits without refs."},{"id":"c","text":"--simplify-merges","whyNot":"It removes needless merges from the output and is an addition to --full-history."},{"id":"d","text":"--ancestry-path","whyNot":"It limits a commit range to commits that are ancestors or descendants of one given commit."}],"answer":"a","explanation":"--simplify-by-decoration selects the commits that a branch or tag refers to, and may add a few extra commits to keep the history meaningful.","concept":"--simplify-by-decoration selects the commits that a branch or tag refers to, and may add a few extra commits to keep the history meaningful.","rev":1,"updatedAt":"2026-10-23","kind":"scenario","takeaways":["Path limits in git log select the commits that modify those paths.","Use --simplify-by-decoration to focus a long history on commits named by branches and tags."]}]