Both bring changes from one branch into another. Merge ties the two histories together with a merge commit: honest, but branchy. Rebase replays your commits on top of the latest main, as if you started from there: clean, straight history, but it rewrites your commits.
Say it like this in the interview
“Merge preserves history and adds a merge commit; rebase rewrites my branch’s commits onto the new base for a linear history. I rebase my own local feature branch to update it, but never rebase commits others have already pulled, because it rewrites shared history.”
Git couldn’t decide because two people changed the same lines. It marks both versions in the file; you pick or combine them, then tell Git you’re done.
“I open the conflicted files, understand both changes, often by checking the other commit, edit to the correct combined result, remove the markers, run the tests, then git add and continue the merge or rebase. If unsure, I talk to the author of the other change.”
Traps that make people fail
Accepting “mine” for everything without understanding the other change.
Combining many small “wip” commits into one clean commit before merging, so history stays readable.
Say it like this in the interview
“Squash merges or interactive rebase combine a branch’s commits into one meaningful commit. Good for messy feature branches; I keep separate commits when each is a meaningful step.”
Git Flow has long-lived develop and release branches. Trunk-based keeps one main branch with small, frequent merges and feature flags.
Say it like this in the interview
“Git Flow suits scheduled releases but causes long-lived branches and painful merges. Trunk-based development with short-lived branches, CI and feature flags enables continuous delivery and is common in modern teams.”
reset moves the branch backwards as if commits never happened: fine locally, dangerous when shared. revert adds a new commit that undoes the old one: safe for shared branches.
git revert abc123 # safe on shared branches
git reset --soft HEAD~1 # undo last local commit, keep changes staged
git reset --hard HEAD~1 # discard last commit AND changes (careful)
git reflog # find "lost" commits after a bad reset
Say it like this in the interview
“For pushed commits, git revert, which creates an inverse commit without rewriting history. reset is for local cleanup. If I lose work, git reflog shows where HEAD has been so I can recover it.”
Assume it’s already stolen: bots scan GitHub within minutes. Deleting it in a new commit doesn’t help, because it’s still in history.
Say it like this in the interview
“First, rotate/revoke the key immediately, which is the actual fix. Then remove it from history with git filter-repo or BFG if needed, force-push and coordinate with the team, check the provider’s logs for misuse, move secrets to environment variables, and add secret scanning and pre-commit hooks.”
stash puts your unfinished changes in a drawer so you can switch branches with a clean desk. cherry-pick copies one specific commit from another branch onto yours.
Say it like this in the interview
“stash temporarily shelves uncommitted changes; stash pop brings them back. cherry-pick applies a specific commit onto the current branch, useful for hotfixes to a release branch.”
.gitignore only affects files Git isn’t already tracking.
Say it like this in the interview
“The file was committed before. git rm --cached .env stops tracking it while keeping it locally, then commit. If it held secrets, rotate them, since they remain in history.”
Git can do a binary search for you: mark one good and one bad commit, and it keeps cutting the range in half while you test.
Say it like this in the interview
“git bisect start, mark bad and good, test each commit Git checks out; about 8 steps for 200 commits. With git bisect run <test script> it’s fully automated.”