# git & github
// [37] real interview questions. Answers and sources live in the practice app.
practice this topic- What is the difference between git pull and git fetch?(junior)
- What is the difference between git reset and git revert, and when would you use each?(mid)
- You pushed a bad commit to a shared branch and CI/teammates already picked it up. How do you undo it safely?(mid)
- 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)
- What is git reflog and in which situations does it save you?(mid)
- How do you squash the last N commits into a single commit?(mid)
- A teammate's feature branch has dozens of messy commits and needs to land in main. Merge or rebase — what factors decide it?(mid)
- Something broke and you don't know which of the last few hundred commits caused it. How do you find the culprit efficiently?(senior)
- What does git cherry-pick do and when is it the right tool?(mid)
- What does git stash do, and what is the difference between git stash apply and git stash pop?(junior)
- You're in a 'detached HEAD' state and you've made commits. What happened, and how do you keep that work?(mid)
- You added a file to .gitignore but Git keeps tracking it. Why, and how do you fix it?(junior)
- Walk me through resolving a merge conflict.(junior)
- Compare the branching strategies you know (Git flow, GitHub flow, trunk-based). Which fits continuous deployment?(mid)
- You have two branches, main and devel. How do you keep devel in sync with main?(junior)
- How do you discard uncommitted local changes to a file, and how do you discard the last local commit?(junior)
- How do you revert a single file to how it was in a previous commit, without touching anything else?(mid)
- Your last commit is broken. Should you amend it or create a new fix commit? When is amend dangerous?(mid)
- How do you find out which branches have already been merged into main (e.g. to clean them up)?(mid)
- 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)
- 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)
- How does Git store data internally? What's inside a commit object?(mid)
- 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)
- What is a git submodule, when is it the right tool, and why do teams end up regretting them?(mid)
- A teammate cloned your repo and the submodule directories are empty. Why, and what fixes it?(junior)
- What are Git hooks? Give client-side and server-side examples — and explain why client-side hooks can't enforce team policy.(mid)
- What does signing a commit actually prove, and how does GitHub's 'Verified' badge work?(senior)
- Shallow clone, partial clone, sparse checkout — what does each cut, and when do you use which (e.g. in CI)?(senior)
- Your team debates splitting the monorepo into multiple repos stitched together with submodules. What are the real trade-offs?(senior)
- 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)
- 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)
- 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)
- 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)
- 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)
- 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)
- How do you guarantee nothing lands on main without review and green CI — even from admins in a hurry?(mid)
- Designers keep committing large binaries and the repo ballooned to gigabytes. How does Git LFS work, and what are its limits?(mid)