The model
- A commit is a snapshot with a parent pointer; a branch is a movable pointer to a commit; HEAD points at your current position.
- What does detached HEAD mean, and how do you get out of it safely?
- Working directory, staging area, repository - and what moves between them.
- What does a fast-forward merge mean, and when can it not happen?
Merge versus rebase
- Merge preserves history and creates a merge commit; rebase rewrites commits onto a new base for a linear history.
- The golden rule: do not rebase commits others have pulled. Be able to say why - it rewrites hashes, so their history diverges.
- Squash merge, and what it costs you in granularity.
- What is an interactive rebase for? Cleaning a branch before review.
- Which does your team use, and why? A question about judgement rather than correctness.
Undoing things, the scenario round
- Committed to the wrong branch. Branch from here, then reset the original back.
- Need to undo a pushed commit. `revert`, not `reset` - because history others have is not yours to rewrite.
- `reset --soft` versus `--mixed` versus `--hard` - and which one loses work.
- Accidentally reset --hard. `reflog`, find the commit, reset back to it.
- A secret was committed. Rotate the secret first - it is compromised regardless. Then rewrite history and force-push, knowing clones may still hold it.
- Want one commit from another branch. `cherry-pick`.
- Need to pause work. `stash`, and that stashes also appear in reflog.
Conflicts and workflow
What a conflict actually is - the same lines changed on both sides - and how you resolve one deliberately rather than by accepting a side wholesale. Then workflow: trunk-based against long-lived branches, why short-lived branches reduce conflict pain, what a good commit message contains, and what you look for in a pull request. The review-culture half overlaps with QA engineer interview questions.
How deep it goes by level
- Junior: the fundamentals above, explained clearly. Nobody expects production scars yet, and saying what you have not done reads better than bluffing.
- Mid-level: the same ground plus a workflow you have worked in and a recovery you have performed. Expect follow-ups asking why you made a choice rather than whether you know the syntax.
- Senior: branching strategy decisions across teams, and monorepo or history-rewriting migrations. The recall questions get shorter and the judgement questions get longer.
Whatever the level, say your answers out loud rather than reading them. Most of what candidates lose in a Git interview is lost between knowing something and explaining it under observation - the method is in how to use AI for interview prep.
Where CoPilot Interview fits
Disclosure: we build an interview assistant, so treat this as a disclosed pitch. CoPilot Interview is a native Windows and macOS app that puts suggested answers on your own screen in about two seconds, across coding, system design and behavioral rounds, with a permanent free tier that needs no credit card.
Frequently asked questions
What are the most common Git interview questions?
Merge versus rebase and when not to rebase, the difference between reset modes, how to undo a pushed commit, recovering work with reflog, and what to do when a secret has been committed.
How do you undo a commit that has already been pushed?
Use `git revert`, which creates a new commit undoing the change and leaves history intact. `reset` plus a force-push rewrites history that others already have, which breaks their clones and is why it is the wrong tool on a shared branch.
What is the difference between git reset --soft, --mixed and --hard?
`--soft` moves the branch pointer and keeps changes staged, `--mixed` keeps them in the working directory unstaged, and `--hard` discards them entirely. Only `--hard` loses work, and even then the commits are usually recoverable through reflog.
What should you do if you commit a secret?
Rotate the secret first, because it must be treated as compromised the moment it was pushed. Then remove it from history and force-push, while recognising that existing clones and any caching layer may still hold the old objects.
Walk into the round with a second pair of eyes
CoPilot Interview is a native Windows and macOS app that puts suggested answers on your own screen in about two seconds, across coding, system design and behavioral rounds. The free tier is permanent: 15 minutes a day, no credit card.
Try it free