Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get rid of Merge commits in git

I have a repository which is shared by more than 1 person So often I see there are a lot of merge commits in commit history. I want to get rid of them to make my commit history to look cleaner.

What is the practice we should follow to avoid these merge commits? Is it doable ?

I read about merging using --ff-only switch. Can this switch help me ?

like image 739
Sachin Avatar asked Dec 01 '22 03:12

Sachin


1 Answers

If you have your local changes which are not pushed to remote yet, and if you pull latest updates from remote it will create a merge commit. To avoid this try

git pull --rebase
like image 67
mrutyunjay Avatar answered Dec 04 '22 00:12

mrutyunjay