Interview Q&A / Git & GitHub

BeginnerQuick answer1 min readUpdated 3 Oct 2026

What are the three ways to merge a pull request on GitHub?

SHORT ANSWER

Create a merge commit keeps all commits plus a merge commit. Squash and merge combines them into one commit. Rebase and merge replays the commits onto main without a merge commit, giving linear history.

Explain it simply

Three ways to hand in a project: submit the whole notebook with a cover page (merge commit), submit one clean summary page (squash), or copy every page neatly in order (rebase).

Merge commit preserves exact history but adds merge noise. Squash gives one tidy commit per pull request, popular because messy 'fix typo' commits vanish, though detail is lost. Rebase merge keeps individual commits and linear history, but rewrites their hashes. Repository settings decide which options are enabled for a team.

Example

text
Create a merge commit   -> A-B-C-M   (M has two parents)
Squash and merge        -> one commit S containing A+B+C
Rebase and merge        -> A'-B'-C' (new hashes, no merge commit)

What to say in the interview

"Merge commit keeps full history with a merge commit, squash condenses the pull request to one commit, and rebase merge replays the commits linearly. Many teams choose squash for tidy history, and the repository settings control the allowed methods."

#github#pull-request#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.