Git Senior interview questions and answers
76 questions for a Git (Senior) interview - with correct answers, explanations and links to the docs.
Take this quiz- 1.Which four object types make up Git's object database?
- 2.Why does renaming a file not duplicate its content in Git's storage?
- 3.What is a ref in Git internally?
- 4.What does
git gcdo? - 5.How do packfiles keep repositories small?
- 6.Why can a commit that's no longer on any branch still be recovered?
- 7.What is Git moving to as an alternative to SHA-1, and why?
- 8.What does a three-way merge compare?
- 9.What is
ort? - 10.What is the difference between
-s oursand-X oursin a merge? - 11.What is an octopus merge?
- 12.How do you remove a leaked secret from a repository's whole history?
- 13.Why is
git filter-branchdiscouraged today? - 14.A teammate force-pushed and your
maindiverged. What is the safest recovery? - 15.What does a partial clone with
--filter=blob:nonedo? - 16.Why does
git statusget slow in very large repositories, and what helps? - 17.What is a refspec, like
+refs/heads/*:refs/remotes/origin/*? - 18.Submodule vs subtree: what's the key trade-off?
- 19.Why can a revert of a merge cause trouble when the branch is merged again later?
- 20.How does
git cherryor patch-id detection help after cherry-picking? - 21.What does
git rebase --update-refshelp with in stacked branches? - 22.What problem does a merge queue solve?
- 23.Why should every commit on
mainbuild and pass tests, not just the PR's final state? - 24.How do you handle untestable commits during
git bisect? - 25.What makes
git bisect run ./test.shwork? - 26.Why might a signed commit still not prove the code is safe?
- 27.What can a server-side
pre-receivehook do that client hooks can't? - 28.What does
git noteslet you attach? - 29.Why can a branch named
featureblock creatingfeature/login? - 30.What is the index (staging area) technically?
- 31.During a conflict, what are index stages 1, 2 and 3?
- 32.How do you get exactly "their" version of a conflicted file during a merge?
- 33.During
git rebase main, what do "ours" and "theirs" refer to? - 34.What does
git replacedo? - 35.What does Git LFS file locking address?
- 36.Why are huge files committed by mistake a long-term problem even after deletion?
- 37.What does Git protocol v2 improve?
- 38.What does
git clone --mirrorproduce? - 39.What is the point of the commit-graph file?
- 40.Why are stacked pull requests used?
- 41.How do Conventional Commits enable automated releases?
- 42.What does
git log --followstruggle with? - 43.Why might
git blameshow the wrong author after a file was split into two? - 44.What is a criss-cross merge history?
- 45.How do you produce a release whose source can be reproduced exactly?
- 46.Why do some teams forbid merge commits from
maininto feature branches? - 47.What happens to open pull requests when you rewrite
main's history? - 48.What is
git bundleuseful for? - 49.Why is
git push origin main:productioninteresting? - 50.What risk comes with
git config --global url."git@github.com:".insteadOf? - 51.How are credentials best handled for HTTPS remotes?
- 52.What does
git maintenance startset up? - 53.Why is "merge commit" vs "squash" a team decision rather than a personal one?
- 54.What is a symbolic ref?
- 55.How can you check that a repository's objects are not corrupted?
- 56.Why is
git push --forceto a shared branch dangerous even with backups on CI? - 57.What is the trade-off of a monorepo with Git compared with many repositories?
- 58.Why do rebased commits keep their original author date but change the committer date?
- 59.What does
git log --cherry-pick --left-right A...Breveal? - 60.How do you prevent a huge
package-lock.jsondiff from drowning the real change in review? - 61.What does a custom merge driver in
.gitattributesallow? - 62.Why is rewriting history in a fork-based open-source project especially disruptive?
- 63.What is the main reason Git can create branches in constant time?
- 64.How does
git rerereinteract with a long rebase you abort and redo? - 65.Why might CI on a shallow clone compute the wrong set of changed files?
- 66.What is a "dangling commit"?
- 67.Why should you avoid putting secrets in commit messages, branch names or tags?
- 68.What does
git switch --orphan docscreate? - 69.Why can two developers see different results from the same
git logcommand? - 70.When is
git merge --no-ffuseful even when a fast-forward is possible? - 71.What does
git range-diffgive a reviewer after a force-pushed PR update? - 72.Why is
git stashrisky as long-term storage? - 73.What does
git log --merges --first-parentlist onmain? - 74.What is the cost of a very large number of refs (for example millions of PR refs)?
- 75.Why is
git worktreesafer than cloning the repo twice for parallel work? - 76.What happens to commit hashes when you rebase onto the same base without changes?