# git & github

// [37] real interview questions. Answers and sources live in the practice app.

practice this topic
  1. What is the difference between git pull and git fetch?(junior)
  2. What is the difference between git reset and git revert, and when would you use each?(mid)
  3. You pushed a bad commit to a shared branch and CI/teammates already picked it up. How do you undo it safely?(mid)
  4. A branch that had pushed work was accidentally deleted — both on the remote and on every teammate's machine. How do you recover it?(senior)
  5. What is git reflog and in which situations does it save you?(mid)
  6. How do you squash the last N commits into a single commit?(mid)
  7. A teammate's feature branch has dozens of messy commits and needs to land in main. Merge or rebase — what factors decide it?(mid)
  8. Something broke and you don't know which of the last few hundred commits caused it. How do you find the culprit efficiently?(senior)
  9. What does git cherry-pick do and when is it the right tool?(mid)
  10. What does git stash do, and what is the difference between git stash apply and git stash pop?(junior)
  11. You're in a 'detached HEAD' state and you've made commits. What happened, and how do you keep that work?(mid)
  12. You added a file to .gitignore but Git keeps tracking it. Why, and how do you fix it?(junior)
  13. Walk me through resolving a merge conflict.(junior)
  14. Compare the branching strategies you know (Git flow, GitHub flow, trunk-based). Which fits continuous deployment?(mid)
  15. You have two branches, main and devel. How do you keep devel in sync with main?(junior)
  16. How do you discard uncommitted local changes to a file, and how do you discard the last local commit?(junior)
  17. How do you revert a single file to how it was in a previous commit, without touching anything else?(mid)
  18. Your last commit is broken. Should you amend it or create a new fix commit? When is amend dangerous?(mid)
  19. How do you find out which branches have already been merged into main (e.g. to clean them up)?(mid)
  20. A team's monorepo has grown to hundreds of thousands of files and git status/add take forever. Why, and what can you do?(senior)
  21. Your team mixes Windows and Linux machines and files keep showing as fully modified because of line endings. How do you fix this with Git?(mid)
  22. How does Git store data internally? What's inside a commit object?(mid)
  23. You're mid-refactor with a dirty working tree and must ship an urgent hotfix on another branch. What does git worktree give you that stash or a second clone doesn't?(senior)
  24. What is a git submodule, when is it the right tool, and why do teams end up regretting them?(mid)
  25. A teammate cloned your repo and the submodule directories are empty. Why, and what fixes it?(junior)
  26. What are Git hooks? Give client-side and server-side examples — and explain why client-side hooks can't enforce team policy.(mid)
  27. What does signing a commit actually prove, and how does GitHub's 'Verified' badge work?(senior)
  28. Shallow clone, partial clone, sparse checkout — what does each cut, and when do you use which (e.g. in CI)?(senior)
  29. Your team debates splitting the monorepo into multiple repos stitched together with submodules. What are the real trade-offs?(senior)
  30. You rebase a long-lived branch repeatedly and resolve the SAME conflicts every time. What is git rerere, and why does enabling it seem to 'do nothing' at first?(mid)
  31. Mid interactive rebase, things went wrong: one run shows only 'noop', and in another you deleted a todo line and a commit vanished. What happened in each case, and how do you recover?(senior)
  32. After rebasing, your push is rejected as non-fast-forward. What does --force-with-lease do that --force doesn't, and when is force-pushing acceptable at all?(mid)
  33. An API key was committed and pushed weeks ago; it's buried under newer commits. Walk through the full remediation — and why rewriting history alone is never enough.(senior)
  34. Some code disappeared and nobody knows when. How do you find the commit that introduced or removed a given string, or follow one function's history?(mid)
  35. A tracked config file needs local-only edits (e.g. credentials in a template) and Git must stop seeing it as modified. .gitignore doesn't work — what does, and what are the pitfalls?(mid)
  36. How do you guarantee nothing lands on main without review and green CI — even from admins in a hurry?(mid)
  37. Designers keep committing large binaries and the repo ballooned to gigabytes. How does Git LFS work, and what are its limits?(mid)