What is a fast-forward merge in Git?

If the target branch has no new commits since your branch was created, Git does not need a merge commit. It just moves the pointer of the target branch forward to the last commit of your branch.

Terminal output

$ git merge feature
Updating 0057196..22ea2c5
Fast-forward
g.txt | 1 +
1 file changed, 1 insertion(+)
create mode 100644 g.txt

To force a merge commit even in this case, use git merge --no-ff. See Git Merge.


Learn more about the similar topics:
Tutorials
Git Branch
Git Checkout and Switch
Git Merge
Git Merge Conflict
Git Rebase
Git Cherry Pick
Git Branching Strategy
Exercises & Assignments
Create a new branch and switch to it
Merge a feature branch into main
Resolve a merge conflict
Delete a merged branch
Rename a local branch
Copy one commit to another branch with cherry-pick
Interview Questions & Answers
How you can see list of all branches in Git?
How do I create a new branch in Git?
How to switch to an another branch in Git?
How to merge one branch to another in Git?
How to rename a local Git branch?
What is the difference between git merge and git rebase?
What is a merge conflict and how do you resolve it?