Interview Q&A / Git & GitHub

AdvancedQuick answer1 min readUpdated 3 Oct 2026

What does git revert -n (--no-commit) do?

SHORT ANSWER

It applies the reverse of a commit to your working tree and index without committing. This lets you revert several commits and record them together as a single commit.

Explain it simply

Normal revert makes one commit per reverted commit. If a feature came in as five commits and you want it out, five revert commits are noise.

With -n, Git applies each reversal but stops before committing. Revert them all, review with git diff --staged, then make one commit with a meaningful message, such as 'Remove beta search feature'. If conflicts appear they arrive as usual. git revert --abort cancels a multi-step revert.

Example

bash
git revert -n a1b2c3d
git revert -n d4e5f6a
git diff --staged
git commit -m "Remove beta search feature"

What to say in the interview

"git revert -n applies the inverse changes without creating commits, so I can revert several commits and commit once with a clear message. I review with git diff --staged before committing."

#git#revert#commit

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.