Tuesday, May 18, 2021

Git Basics - disable fast forward merge

 Use merge with --no-ff

When you use git it does FAST-FORWARD merge. How to disable or avoid this.

Let's look with below scenario


git status ->  verify clean

git checkout -b new-branch -> will create "new-branch" and switch to it.

mate test.html

git commit -am "adding content"

git log --oneline --graph --decorate

Now you are going to merge to 'master'. So first checkout/switch to master branch 

git checkout master

disable fast forward merge 

git merge new-branch --no-ff


Now if you do git log ,you can see the changes

git log --oneline --graph --decorate

Let's delete that branch

git branch -d new-branch

Check the log

git log --oneline --graph --decorate

No comments:

Post a Comment