Interview Q&A / Git & GitHub

INTERVIEW Q&A · 97 QUESTIONS

Git & GitHub interview questions

Branching, merge vs rebase, resolving conflicts and pull requests, the way teams actually work.

  1. What is the difference between git merge and git rebase?

    Both bring changes from one branch into another. Merge joins the two histories with a new merge commit and keeps everything as it happened. Rebase replays your commits on top of the other branch, giving a straight, linear history but rewriting commit IDs. Never rebase commits that others have already pulled.

    IntermediateIn-depth3 min read
  2. How does a three-way merge work in Git?

    Git compares three snapshots: the two branch tips and their common ancestor. Changes made on only one side are taken automatically; if both sides changed the same lines differently, Git reports a conflict.

    IntermediateQuick answer1 min read
  3. What does git merge --squash do?

    It combines all changes from a branch into the working tree and staging area as one set of changes, without creating a merge commit. You then commit once, so the branch's many commits become a single commit on main.

    IntermediateQuick answer1 min read