Git Interview Questions

The object model that explains everything else — branching and merging, rebase and history rewriting, undoing mistakes and recovering lost work, collaboration workflows, and the tools most people never use.

Object ModelMergingRebaseRecoveryWorkflowsAria-powered explanations
0 / 100 answered
0%
16 Easy60 Medium24 Hard

Showing 120 of 100

#1What are the four Git object types and how do they fit together?

Medium
Fundamentals

#2What is a branch in Git, really?

Easy
Fundamentals

#3What are the three trees — working directory, index, and HEAD?

Medium
Fundamentals

#4Why does Git store snapshots rather than diffs?

Medium
Fundamentals

#5What is the difference between git fetch, pull, and clone?

Easy
Fundamentals

#6What is HEAD and what does detached HEAD mean?

Medium
Fundamentals

#7What is the difference between a lightweight and an annotated tag?

Easy
Fundamentals

#8What does the index actually store?

Hard
Fundamentals

#9How does Git determine whether a file was renamed?

Medium
Fundamentals

#10What is the difference between .gitignore and .git/info/exclude?

Easy
Fundamentals

#11What is the reflog and why is it the most useful recovery tool?

Medium
Fundamentals

#12What happens during git gc?

Hard
Fundamentals

#13What is the difference between origin/main and main?

Easy
Fundamentals

#14Why do two identical-looking commits have different hashes?

Medium
Fundamentals

#15What is a fast-forward merge and when does it not happen?

Easy
Branching & Merging

#16How does a three-way merge work?

Medium
Branching & Merging

#17How do you resolve a merge conflict properly?

Medium
Branching & Merging

#18What is the difference between merge and rebase?

Medium
Branching & Merging

#19What is a squash merge and what do you lose?

Medium
Branching & Merging

#20What is git cherry-pick and when is it appropriate?

Medium
Branching & Merging

Showing 120 of 100

Ask Aria about Git

Sign in to chat with Aria

All 100 Git questions at a glance
  1. What are the four Git object types and how do they fit together?(Medium)
  2. What is a branch in Git, really?(Easy)
  3. What are the three trees — working directory, index, and HEAD?(Medium)
  4. Why does Git store snapshots rather than diffs?(Medium)
  5. What is the difference between git fetch, pull, and clone?(Easy)
  6. What is HEAD and what does detached HEAD mean?(Medium)
  7. What is the difference between a lightweight and an annotated tag?(Easy)
  8. What does the index actually store?(Hard)
  9. How does Git determine whether a file was renamed?(Medium)
  10. What is the difference between .gitignore and .git/info/exclude?(Easy)
  11. What is the reflog and why is it the most useful recovery tool?(Medium)
  12. What happens during git gc?(Hard)
  13. What is the difference between origin/main and main?(Easy)
  14. Why do two identical-looking commits have different hashes?(Medium)
  15. What is a fast-forward merge and when does it not happen?(Easy)
  16. How does a three-way merge work?(Medium)
  17. How do you resolve a merge conflict properly?(Medium)
  18. What is the difference between merge and rebase?(Medium)
  19. What is a squash merge and what do you lose?(Medium)
  20. What is git cherry-pick and when is it appropriate?(Medium)
  21. What is git rerere and what problem does it solve?(Hard)
  22. How do you keep a long-lived feature branch current?(Medium)
  23. What causes a merge conflict that Git could have avoided?(Medium)
  24. What are the merge strategies and when would you change from the default?(Hard)
  25. What is an octopus merge?(Hard)
  26. How do you find which commit introduced a bug?(Medium)
  27. What does git blame tell you and what are its limits?(Medium)
  28. What is a merge commit and should you avoid them?(Medium)
  29. What does git rebase actually do, step by step?(Medium)
  30. What is interactive rebase used for?(Medium)
  31. Why is rebasing published history dangerous?(Medium)
  32. What is the difference between --force and --force-with-lease?(Hard)
  33. What is git commit --amend and when should you not use it?(Easy)
  34. How do you split one commit into several?(Hard)
  35. How do you remove a secret that was committed?(Hard)
  36. What is git filter-repo and why replace filter-branch?(Hard)
  37. What does git rebase --onto do?(Hard)
  38. What makes a good commit message?(Easy)
  39. How should you structure a series of commits in a pull request?(Medium)
  40. What is git commit --fixup and --autosquash?(Hard)
  41. When is it acceptable to rewrite history?(Medium)
  42. How do you recover from a rebase that went wrong?(Medium)
  43. What is a remote and how do remote-tracking branches work?(Easy)
  44. What is the difference between git push and git push -u?(Easy)
  45. How do you contribute to a project you do not have write access to?(Easy)
  46. What is a shallow clone and when is it useful?(Medium)
  47. What are Git submodules and what are their problems?(Hard)
  48. What is Git LFS and when do you need it?(Medium)
  49. How do Git hooks work and what are they used for?(Medium)
  50. What is a bare repository?(Medium)
  51. How do you handle a large binary accidentally committed?(Hard)
  52. What is the difference between a fork and a branch?(Easy)
  53. How do you sign commits and why would you?(Medium)
  54. What is git worktree and what problem does it solve?(Medium)
  55. What is the difference between git reset --soft, --mixed and --hard?(Medium)
  56. When do you use git revert instead of git reset?(Medium)
  57. How do you undo changes to a file in the working directory?(Easy)
  58. How does git stash work and what are its pitfalls?(Medium)
  59. How do you recover a deleted branch?(Medium)
  60. How do you undo a git push?(Medium)
  61. How do you recover a commit after a hard reset?(Medium)
  62. How do you remove a file from the last commit without losing it?(Medium)
  63. What does git clean do and why is it dangerous?(Medium)
  64. How do you undo a merge that has already been pushed?(Hard)
  65. How do you fix a commit made on the wrong branch?(Medium)
  66. What is git reset --hard ORIG_HEAD and when is it useful?(Medium)
  67. You committed with the wrong author. How do you fix it?(Medium)
  68. What is the safest way to experiment with a risky Git operation?(Medium)
  69. What is Git Flow and what are its criticisms?(Medium)
  70. What is trunk-based development?(Medium)
  71. What branch protection rules would you configure?(Medium)
  72. Should you squash, rebase, or merge pull requests?(Medium)
  73. How do you handle hotfixes to production?(Medium)
  74. How do you manage releases with tags?(Medium)
  75. What is a monorepo and what are the Git implications?(Hard)
  76. How do you review a large pull request effectively?(Medium)
  77. What Git configuration would you set on a new machine?(Medium)
  78. How do you handle a repository with an inconsistent commit history?(Medium)
  79. What is the difference between CI on a branch and CI on the merge result?(Hard)
  80. How should a team decide on a branching strategy?(Medium)
  81. What can you do with git log that most people do not?(Medium)
  82. What is the pickaxe search and when is it the right tool?(Hard)
  83. What does git diff show by default and how do you get the diff you want?(Medium)
  84. What is git add -p and why is it worth using?(Medium)
  85. What are Git attributes used for?(Hard)
  86. What is sparse-checkout and when do you need it?(Hard)
  87. What is git notes and why is it rarely used?(Hard)
  88. How does git bisect run work?(Medium)
  89. What is a refspec?(Hard)
  90. How do you find a commit when you only remember roughly what it did?(Medium)
  91. What is the difference between two-dot and three-dot notation?(Hard)
  92. What are some Git aliases worth setting up?(Easy)
  93. Git says your branch has diverged. What does that mean and what do you do?(Easy)
  94. Why might git status show a file as modified when you have not changed it?(Medium)
  95. Why is a file still tracked after adding it to .gitignore?(Easy)
  96. What causes "refusing to merge unrelated histories"?(Medium)
  97. How do you deal with a repository that has become very slow?(Hard)
  98. Someone force-pushed and your work is gone. What do you do?(Medium)
  99. How do you debug a merge that produced broken code with no conflicts?(Hard)
  100. What is the mental model that makes Git make sense?(Medium)