Interview Prep/Git & GitHub/Branching and Merging Workflows

How do you preview the result of a merge without actually creating a commit?

BeginnerScenarioBranching and Merging Workflows
Answer

Situation read → You want to inspect the merged tree and run tests before committing.

What I'd do →

  1. git merge --no-commit --no-ff feature.
  2. Build and test the working tree.
  3. Accept with git commit, or discard with git merge --abort.

Why → --no-ff ensures a merge is staged even when a fast-forward would be possible; --no-commit stops before creating the commit.

Interview tip → git merge-tree --write-tree main feature can also compute the result without touching your working tree (Git 2.38+).

All Git & GitHub questions Roadmap: Git & GitHub

More on Branching and Merging Workflows