THE GITHTML FIELD GUIDE
Understand fast-forward merges and merge commits
A fast-forward moves a branch to a descendant commit without creating a new merge commit. When branches have diverged, a normal merge combines their histories in a commit with multiple parents. Use --ff-only when you want Git to refuse anything except a direct advance, and inspect the branch relationship before integrating.
Read the ancestry rather than file similarity
Fast-forward eligibility depends on commit ancestry, not whether the final files happen to look similar. If main points to A and feature contains A followed by B and C, main can move directly to C. If main also has a separate commit D, the histories have diverged and a simple pointer advance would omit one line of development.
A merge commit records a combined result and links the histories through its parents. This can preserve the context of parallel work, but the resulting files still need review and tests. Git can automatically combine nonoverlapping text while producing behavior that is wrong at the application level. A clean merge is not the same as a validated change.
Inspect and request the intended integration
Begin with a clean or deliberately preserved working state. The example assumes you are on the destination branch and feature/search is the branch you want to integrate. Review the graph before running the final command. --ff-only is useful when a direct advance is required and a merge commit would be unexpected.
- If the command refuses because a fast-forward is impossible, inspect the divergent commits and agree on merge or rebase policy rather than forcing a branch pointer.
- If the project deliberately requires a merge commit, follow that policy after review; do not infer it from a tutorial’s command defaults.
git status --short --branch
git log --graph --oneline --decorate -15
git log --oneline HEAD..feature/search
git merge --ff-only feature/searchCheck the resulting history and behavior
After integration, inspect the recent graph and current commit. A fast-forward should show the destination now pointing at the existing descendant commit. A true merge creates a new commit linking the histories. If conflicts occur during a merge, Git pauses for a resolution; read status and avoid starting unrelated operations while the merge remains unfinished.
Before sharing the result, run the tests relevant to both lines of work and inspect the combined diff against the old destination. If you began with unrelated local modifications, confirm they survived as intended. Branch policy should support review and recovery, not just a preferred graph shape. Being able to explain which commits are now reachable and why is more valuable than memorizing a command that always produces one visual style.
Keep the original destination commit identifier in your review notes when the integration is significant. It gives a precise comparison point without requiring anyone to infer the old state.
Sources and further reading
AI-assisted writing with source-linked guidance and illustrative examples. Read our editorial approach or report a correction.