Skip to content

Quiz: Git

← Back to quiz index

4 questions

L0 (1 questions)

1. What are the three local areas in Git where changes live?

Show answer Working directory (your actual files on disk), staging area/index (changes queued for next commit via 'git add'), and local repository (committed snapshots stored in .git/). Changes flow: working dir -> staging -> repository -> remote.

L1 (1 questions)

1. What is the golden rule of rebase, and what happens if you violate it?

Show answer Never rebase commits that have been pushed to a shared branch. Rebase rewrites commit hashes, so if others have already pulled those commits, their history diverges from the rebased history. This causes duplicate commits, merge conflicts, and confusion. Rebase is safe only for local branches that have not been shared.

L2 (1 questions)

1. Something broke between Monday and Friday across 25 commits. How do you efficiently find the breaking commit?

Show answer Use git bisect: 'git bisect start', 'git bisect bad HEAD' (current broken state), 'git bisect good '. Git checks out the midpoint — test it, mark good or bad, and repeat. Binary search finds the exact commit in log2(25) = ~5 tests instead of 25. Run 'git bisect reset' when done.

L3 (1 questions)

1. You accidentally committed an API key 3 commits ago. The key has been rotated, but how do you remove it from Git history entirely?

Show answer Use 'git filter-branch' or the modern 'git filter-repo' tool to rewrite history and remove the file/line containing the key. This changes all subsequent commit hashes. Force-push to the remote and have all collaborators re-clone or reset. Also check: GitHub/GitLab cache (may need repo support to purge), any forks, and CI build logs. Prevention: use pre-commit hooks with git-secrets or detect-secrets.