how/history
You "merged the branch" but how? Without a merge commit or with one? What does "branches diverged" mean, and why does --no-ff exist? The commit graph shows it all in a second.
git merge feat can end in two completely
different ways, and which one happens decides how the history
looks afterward.
Press ▶ to see five scenarios. The same git merge feat behaves
differently depending on what was on main.
Starting state:
main: A
↘
feat: A → B → C
main has only commit A. feat has A → B → C. The key point: main
has no new commits after the branching point. This means the tip of main
(A) is an ancestor of the tip of feat (C).
In Git this is exactly the condition for fast-forward: the target branch lags on a straight line behind the source.
recap
What to remember:
refs/heads/main to the SHA of feat's tip.
No new commits appear, the history stays linear, and the fact of
branching disappears.git merge --no-ff feat forces a merge commit even
when FF is possible. Useful when you want the log to show "there was a
feat branch here." In GitHub-flow, PRs are merged exactly this way.git merge --ff-only feat is the opposite: "if FF is not possible, do
nothing." It protects you from accidental merge commits in git pull
(see pull.ff = only).git rebase feat onto main is a third path: move feat's commits
on top of main so that FF becomes possible again. The history stays
linear, but the commit SHAs change (same diff, new parent =
new hash). So you can only rebase what nobody has
pulled yet.What to choose in practice:
--no-ff (the standard for PR forges).rebase (or
git pull --rebase).ff is fine, the history is cleaner.