Fast Foward Merge
View commit history with graph
git log --oneline --all --graph
Merge branch to Master
- Switch to master
- Then merge
git switch master
git merge bugfix-signup-form
Create and Switch Branch
git switch -C bugfix-login-form
Merge branch to Master without Fast-Forward
git merge --no-ff bugfix-login-form
Benefits of disabling Fast Forward
- Merge commits are a true reflection of history, a true reflection of what actually happened when we merged our branches and how they were merged.
- Merge commits have another benefit, they make it easier for us to undo a feature.
- By reverting a commit, we create a new commit, that is the opposite of that commit.
- Reverting undoes everything that has happened in another commit. So if we use a merge commit, there is a single commit that we have to revert.
- If we use the Fast Forward option, our master pointer is going to move over here. And now if you want to take out this feature from the codebase, we have more commits that we have to revert, and this can get a bit more complex.
Disabling Fast Forward
Locally for single repository
git config ff no
Globally
git config --global ff no