[{"id":"gitadvanced-001","courseId":"git-advanced","domain":"repository-basics","topic":"Index stat data per entry","prompt":"Git caches file metadata in each index entry so it can spot changed files quickly. Put these stat fields in the order they appear within one entry, first to last.","hint":"Read the entry layout from top to bottom; each field is a fixed 32-bit value.","explain":"An index entry caches stat(2) results for each tracked file, so Git can spot changes without rereading content. Its fields are fixed-width binary numbers.","source":"https://git-scm.com/docs/gitformat-index","interaction":{"type":"sort","items":[{"text":"32-bit ctime seconds","why":"The entry opens with the time the file's metadata last changed."},{"text":"32-bit mtime seconds","why":"The time the file's data last changed comes after the change-time fields."},{"text":"32-bit dev","why":"The device number follows the timestamp fields."},{"text":"32-bit mode","why":"The mode, with its object type and permission bits, comes after dev and ino."},{"text":"32-bit file size","why":"The on-disk size sits near the end, after uid and gid."}]},"options":[],"answer":"o:abcde","explanation":"Each index entry stores stat fields such as ctime, mtime, dev, ino, mode and size as fixed 32-bit values in a fixed sequence.","concept":"Each index entry stores stat fields such as ctime, mtime, dev, ino, mode and size as fixed 32-bit values in a fixed sequence.","rev":1,"updatedAt":"2026-10-23","kind":"scenario","takeaways":["Index entries cache stat data, so Git can skip rereading unchanged files."]},{"id":"gitadvanced-002","courseId":"git-advanced","domain":"repository-basics","topic":"Last matching ignore pattern wins","prompt":"A repo's root .gitignore contains the three lines shown. Git checks a file named notes.txt in the repo root. Is it ignored?","hint":"Ask which matching line comes last in the file, not which one comes first.","explain":"Git checks each path against the lines of a gitignore file in order. A line starting with ! can bring back a path that an earlier line excluded, and one path can match several lines.","source":"https://git-scm.com/docs/gitignore","interaction":{"type":"single"},"options":[{"id":"a","text":"Not ignored, because the !notes.txt line re-includes it","whyNot":"A negation only undoes matches from earlier lines, so the later notes.txt line still applies."},{"id":"b","text":"Ignored, because the last matching line, notes.txt, decides","why":"Git scans the lines in order and the last one that matches a path sets its fate, so the final plain pattern wins."},{"id":"c","text":"Git rejects the pattern list, since notes.txt appears twice","whyNot":"Repeated patterns are allowed; Git simply evaluates each line in turn."},{"id":"d","text":"Ignored only if notes.txt is a directory","whyNot":"A pattern without a trailing slash matches both files and directories, so files are covered too."}],"answer":"b","explanation":"Within one gitignore level, the last pattern that matches a path decides whether it is ignored; a later plain pattern overrides an earlier ! negation.","concept":"Within one gitignore level, the last pattern that matches a path decides whether it is ignored; a later plain pattern overrides an earlier ! negation.","rev":1,"updatedAt":"2026-10-23","kind":"scenario","code":"*.txt\n!notes.txt\nnotes.txt","takeaways":["In a gitignore file the last matching line decides, so line order matters for ! rules."]},{"id":"gitadvanced-003","courseId":"git-advanced","domain":"repository-basics","topic":"Deeper .gitignore files override","prompt":"The root .gitignore contains *.log. The file src/.gitignore contains !debug.log. Git checks the path src/debug.log. Which TWO statements about this are correct?","hint":"Think about which file level wins when two .gitignore files disagree.","explain":"Git can read several gitignore files, one per directory level. Files closer to a path take priority over those above them, and command-line patterns outrank every file.","source":"https://git-scm.com/docs/gitignore","interaction":{"type":"multiple","tellCount":true},"options":[{"id":"a","text":"src/debug.log is not ignored, because the deeper src/.gitignore overrides the root *.log pattern.","why":"Patterns in lower-level .gitignore files override those in higher-level files, so the negation wins."},{"id":"b","text":"The root .gitignore wins, because files at higher levels are read first.","whyNot":"Higher-level files are overridden by lower-level ones, so reading order gives no priority."},{"id":"c","text":"Deleting the !debug.log line from src/.gitignore makes src/debug.log ignored again.","why":"With no override left, the root *.log pattern matches src/debug.log, since a pattern without a slash matches at any depth below its file."},{"id":"d","text":"Only a command-line pattern can override a .gitignore pattern.","whyNot":"Command-line patterns rank highest, but a deeper .gitignore file also overrides a higher one."},{"id":"e","text":"A pattern in $GIT_COMMON_DIR/info/exclude beats src/.gitignore.","whyNot":"info/exclude ranks below .gitignore files, so src/.gitignore still takes precedence."},{"id":"f","text":"The !debug.log line has no effect, since negations work only in the root file.","whyNot":"Negation works in any .gitignore file, and here it changes the outcome for src/debug.log."}],"answer":"ac","explanation":"Patterns in a deeper .gitignore override higher-level files; the precedence runs command line, then .gitignore files, then info/exclude, then core.excludesFile.","concept":"Patterns in a deeper .gitignore override higher-level files; the precedence runs command line, then .gitignore files, then info/exclude, then core.excludesFile.","rev":1,"updatedAt":"2026-10-23","kind":"scenario","takeaways":["A negated pattern in a subdirectory .gitignore can re-include files the root excluded."]},{"id":"gitadvanced-004","courseId":"git-advanced","domain":"repository-basics","topic":"Untracked cache speeds status","prompt":"You want to turn on the untracked cache for a repo on a network file system. In current Git, which step should you take before enabling it?","hint":"The cache trusts a directory's modification time, so ask what must be true of the filesystem.","explain":"The untracked cache records each directory's modification time and skips re-reading directories whose time has not changed. That only works if the file system updates directory times when files change.","source":"https://git-scm.com/docs/git-update-index","interaction":{"type":"single"},"options":[{"id":"a","text":"Nothing: the cache checks each file's own mtime, not the directory's","whyNot":"The cache depends on directory mtimes, so a filesystem that does not update them breaks it."},{"id":"b","text":"Run git update-index --test-untracked-cache to check that the filesystem updates directory mtimes","why":"The cache skips directories whose mtime has not changed, so the filesystem must update directory mtimes; this option tests that."},{"id":"c","text":"Run git update-index --untracked-cache, which tests the filesystem first","whyNot":"Older Git ran that test implicitly, but current Git no longer does, so the explicit test is needed."},{"id":"d","text":"Enable core.fsmonitor first, since the untracked cache needs it","whyNot":"The untracked cache works on its own; FSMonitor is an optional companion that can add speed."}],"answer":"b","explanation":"The untracked cache relies on directory mtimes; --test-untracked-cache checks the filesystem, and --untracked-cache no longer runs that test implicitly.","concept":"The untracked cache relies on directory mtimes; --test-untracked-cache checks the filesystem, and --untracked-cache no longer runs that test implicitly.","rev":1,"updatedAt":"2026-10-23","kind":"scenario","takeaways":["Test the untracked cache on new filesystems before trusting git status output."]},{"id":"gitadvanced-005","courseId":"git-advanced","domain":"repository-basics","topic":"Sparse index for large repositories","prompt":"Your repo uses a sparse index, and an older Git version fails to read it. Which fix does the sparse-checkout documentation recommend?","hint":"Look at the warning about compatibility with older Git versions.","explain":"A sparse index stores entries only for the parts of the tree your sparse-checkout includes. Older Git versions may not understand this index extension at all.","source":"https://git-scm.com/docs/git-sparse-checkout","interaction":{"type":"single"},"options":[{"id":"a","text":"Switch to --no-cone mode, which keeps the sparse index readable by older Git","whyNot":"Non-cone mode has drawbacks, including not working with some sparse-index options, and the docs advise against it."},{"id":"b","text":"Run git sparse-checkout reapply --sparse-index to rebuild the index","whyNot":"That flag asks for the sparse index again, so older Git would still face the same index."},{"id":"c","text":"Run git sparse-checkout init --no-sparse-index to rewrite the index as a full index","why":"The docs give this command to rewrite the index so it is not sparse when compatibility problems appear."},{"id":"d","text":"Run git sparse-checkout clean -f to shrink the index","whyNot":"clean removes files outside the sparse definition from the working tree; it does not change the index format."}],"answer":"c","explanation":"A sparse index can break older Git; sparse-checkout init --no-sparse-index rewrites the index to a full one, the documented fix.","concept":"A sparse index can break older Git; sparse-checkout init --no-sparse-index rewrites the index to a full one, the documented fix.","rev":1,"updatedAt":"2026-10-23","kind":"scenario","takeaways":["Older Git versions may fail on a sparse index until it is disabled."]}]