Interview Q&A / Git & GitHub

BeginnerQuick answer1 min readUpdated 3 Oct 2026

How do you cancel a merge that went wrong?

SHORT ANSWER

Run git merge --abort. It restores your branch and working tree to the state before the merge started. It works while the merge is still unresolved and uncommitted.

Explain it simply

You started a merge, saw forty conflicted files and thought 'not today'. There is an exit.

git merge --abort throws away the half-done merge and returns you to exactly where you were. If you already committed the merge, abort no longer applies; use git reset --hard ORIG_HEAD right after the merge, or git revert -m 1 if it was pushed. Similar escape hatches exist for other operations: git rebase --abort and git cherry-pick --abort.

Example

bash
git merge feature/redesign
# CONFLICT (content): Merge conflict in app.css
git merge --abort
git status      # clean again

What to say in the interview

"git merge --abort returns to the pre-merge state if the merge is still in progress. After a committed merge I would use reset to ORIG_HEAD if unpushed, or revert -m 1 if pushed. Rebase and cherry-pick have their own --abort."

#git#conflicts#merge

Related questions

Practise more Git & GitHub questions

Test your recall with short answers, then return to the detailed explanations when you need context.

Open Git & GitHub quick answers →

Get new questions like this by email

One short email when something new and useful lands. No spam, unsubscribe in one tap.

By subscribing you agree to the Privacy Policy.