A team branching strategy, a critical merge conflict right before deployment, how rebase works and when to prefer it, managing conflicts, rebase vs merge trade-offs, cloning, git pull (and pull --rebase), pulling in a teammate's unmerged work, fixing a mistake in an older commit, and reviewing many pull requests.
Published September 25, 2026
At 2–5 years, Git questions test judgement under pressure: rewriting history safely, resolving conflicts in critical code, and keeping a team's history useful. Give the commands, and the rule that keeps them safe.
Short answer: Keep main always releasable, and protected (required reviews, required CI checks, no direct pushes). Work on short-lived feature branches (days, not weeks), cut from the latest main. Merge through pull requests with automated tests, then delete the branch. Hide unfinished work behind feature flags, instead of long-lived branches. Use release branches only if you must support several versions.
Key points to cover:
feature/ORD-123-export, fix/…), and use Conventional Commits for readable history and automated changelogs.Short answer:
git log -p), and bring in the authors.Key points to cover:
git rebase work, and when should you use it instead of merge?Short answer: git rebase main takes the commits that are on your branch but not on main, temporarily removes them, moves your branch to the tip of main, and replays each commit on top, creating new commits with new hashes. The result is linear history, as if you'd started from the latest main.
Use rebase to update your own feature branch, and to clean it up before merging (squash fixup commits, reword messages). Use merge for integrating shared branches, and whenever the branch has already been pulled by others.
git fetch origin
git rebase origin/main # replay my commits on the newest main
git rebase -i origin/main # optionally squash/reorder/reword before the PR
git push --force-with-lease # the branch was already pushed: update it safely
Common trap: rebasing a shared branch, such as main or a branch teammates have based work on. Rewriting published history forces everyone to recover their clones.
Short answer:
git status lists the conflicted files.<<<<<<< / ======= / >>>>>>> regions by intent, not by picking a side blindly.git mergetool or your IDE's three-way merge view, which shows the base, ours and theirs.git add the resolved files, then git commit (for a merge) or git rebase --continue (for a rebase).git merge --abort / git rebase --abort.Key points to cover:
git config merge.conflictStyle zdiff3 shows the base version inside the conflict markers, which makes intent clear.rerere.enabled=true remembers resolutions for repeated rebases.Short answer: Rebase rewrites your branch's commits onto a new base. Its advantages: a linear, readable history, no noisy "Merge main into feature" commits, easier git bisect and git log, and the chance to tidy commits before review.
Its costs:
Merge preserves the true history, at the cost of a more tangled graph.
Key points to cover:
main through the platform.Short answer: git clone <url>. Use SSH (git@github.com:org/repo.git) for key-based authentication, or HTTPS with a token or credential manager. Useful options:
--branch <name> to check out a specific branch;--depth 1 (a shallow clone for CI);--filter=blob:none (a partial clone for huge repositories);--recurse-submodules.The GitHub CLI's gh repo clone org/repo also works.
git pull do?Short answer: git pull = git fetch (download new commits into origin/<branch>) plus integrating them into your current branch. By default that's a merge, or with --rebase, a rebase. With --ff-only, it only fast-forwards.
git config --global pull.rebase true # avoid needless merge commits on pull
git pull --ff-only # refuse anything but a clean fast-forward (good for main)
Key points to cover:
git fetch first, and inspect with git log HEAD..origin/main, before integrating.Short answer: The options, in order of preference:
main, then rebase onto main. This keeps both histories clean.git fetch origin && git rebase origin/their-feature (or git merge origin/their-feature). Coordinate, because their branch may be rebased under you.git cherry-pick <sha>. Be aware that it duplicates the commit, and can cause conflicts later.Key points to cover:
Short answer:
edit and amend it, or better, commit the fix as a fixup and let Git squash it in.git commit --fixup=<sha-of-bad-commit>
git rebase -i --autosquash <sha-of-bad-commit>~1 # folds the fix into the original commit
git revert the bad commit.Short answer:
Learn it in depth → Volunteer for PR Reviews
Q: What's the difference between squash-merge and rebase-merge on a PR?
A: Squash-merge collapses the whole PR into one commit on main: a clean history, one commit per feature. Rebase-merge replays each PR commit linearly, keeping individual commits. That's useful when the commits are meaningful, and already tidied.
Q: What does --force-with-lease protect against?
A: It refuses to overwrite the remote branch if it has moved since your last fetch (for example, because a teammate pushed). Plain --force would silently discard their commits.
Q: How do you find which commit introduced a bug?
A: git bisect start, then mark a bad and a good commit, and Git binary-searches the history. git bisect run ./test.sh automates the whole search.
Q: What is git reflog, and why is it a safety net?
A: A local log of every position of HEAD and your branch tips. After a bad reset or rebase, you can find the lost commit there, and restore it with git reset --hard <sha> or git branch rescue <sha>.