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 →
git merge --no-commit --no-ff feature.- Build and test the working tree.
- Accept with
git commit, or discard withgit 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+).
More on Branching and Merging Workflows
You run `git pull` and Git stops with a merge conflict in `app.py`. What do you do?BeginnerYour feature branch is three weeks old and `main` has moved a lot. Merge `main` in, or rebase onto it?IntermediateThe team argues about fast-forward merges versus merge commits on `main`. How do you settle it?BeginnerA teammate branched from the wrong base, and their PR shows 40 unrelated commits. How do you fix it?IntermediateBefore merging, you want to see exactly what the feature branch adds compared to `main`. Which commands?BeginnerHalfway through a merge you realise you pulled the wrong branch. How do you back out?Beginner