Back to the Catalog
git
version-control
collaboration
dag

Read the Git Graph: Commits, Parents & What Rewriting Really Does

29 questions

Git is a graph, not a timeline. Almost every confusing thing it does makes sense the moment you can see the parent pointers. This quiz gives you the graph before a command and asks what the graph looks like after — covering merge shapes, rebase and cherry-pick, and the commit-range syntax that trips up even experienced users. Recovery (reflog, reset --hard rescues) is out of scope by design.

Questions

  1. Not answered. What does a Git commit object actually store?
  2. Not answered. Which statements about a Git branch name (like main or feature) are true?
  3. Not answered. In the normal, non-detached case, what does HEAD point to?
  4. Not answered. You run git checkout a1b2c3d, where a1b2c3d is a commit SHA, not a branch name. What changes on the graph?
  5. Not answered. "Commit X is on branch main" is really a claim about ancestry. Which statements about that claim are true?
  6. Not answered. You're on main and run git merge feature, creating a merge commit. That commit has two parents. Which one is main's previous tip?
  7. Not answered. Why can plain git log output on a merge-heavy repository look jumbled, with commits from different branches interleaved in a confusing order?
  8. Not answered. On this graph, running git merge feature while checked out on main can complete as a fast-forward. What makes that possible?
  9. Not answered. Which flag, added to git merge, forces Git to always create a real merge commit — even when a fast-forward is possible?
  10. Not answered. On this graph, can git merge feature fast-forward while checked out on main?
  11. Not answered. On a merge-heavy repository, what does git log --first-parent show?
  12. Not answered. You run git merge --squash feature and then commit on main. What does the resulting graph look like?
  13. Not answered. Which statements about git merge --squash are true?
  14. Not answered. On this graph, which commit is the merge base of main and feature?
  15. Not answered. You're checked out on feature and run git rebase main. What happens to feature's three commits, and what does the branch look like afterward?
  16. Not answered. git rebase --onto main featureX topic is run while topic was accidentally branched from featureX instead of from main. Which of topic's commits actually get replayed?
  17. Not answered. In an interactive rebase todo list, which statements about the available actions are true?
  18. Not answered. You run git cherry-pick b7e0c93 to bring one commit from feature onto main. What's true about the result?
  19. Not answered. After cherry-picking a commit from feature onto main (as in the previous graph), you later run an ordinary git merge feature. What can happen?
  20. Not answered. A shared branch is rebased and force-pushed. A teammate already has the old history locally. Which statements about the effect on them are true?
  21. Not answered. What does git push --force-with-lease protect against that plain git push --force does not?
  22. Not answered. Which commits does git log main..feature include on this graph? Select every commit it lists.
  23. Not answered. Which commits does git log main...feature (three dots) include on the same graph? Select every commit it lists.
  24. Not answered. For git diff main...feature (three dots), is the comparison the same symmetric-difference commit set that git log main...feature produces?
  25. Not answered. ^main feature (equivalently, git log ^main feature) is the long form of which two-dot expression?
  26. Not answered. git log branch --not main selects the same commits as which range expression?
  27. Not answered. Using the merge-base graph from earlier, which commits does git log main...feature (three dots) include? Select every commit it lists.
  28. Not answered. Using the after-rebase graph from earlier, what does git log main..feature return now?
  29. Not answered. On the main/feature graph from the two-dot and three-dot questions, how many commits does git log --oneline main..feature print?