Interview Q&A / Git & GitHub

BeginnerQuick answer1 min readUpdated 3 Oct 2026

How big should a commit be?

SHORT ANSWER

One logical change that builds and passes tests on its own. Small, focused commits are easier to review, revert, cherry-pick and bisect than a giant commit mixing several unrelated things.

Explain it simply

Think of a bill split item by item rather than one lump sum. If one item is wrong, you dispute only that line.

A good commit does one job: rename a function, add a validation, fix a bug. If you cannot describe it in one short sentence without 'and', split it. Small commits let you revert only the bad part, let bisect find bugs precisely, and make reviews less tiring. But do not go to extremes with commits that break the build. Use git add -p to split mixed edits.

Example

bash
git add -p            # pick hunks for the first logical change
git commit -m "Validate pin code length"
git add -p            # next change
git commit -m "Rename getUser to fetchUser"

What to say in the interview

"A commit should be one logical, working change that I can describe in a single sentence. Small focused commits are easier to review, revert and bisect, and git add -p helps me split mixed edits."

#git#commit#best-practice

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.