Only You Can Prevent git Merge Commits

Clinton R. Dreisbach, Former Viget

Article Category: #Code

Posted on

a set of merge commits

I love using Git, but when my repositories turn into a tangle of merge commits, I start to get a little frustrated. Here’s my solution. Go into your repo’s .git/config file and make sure it has something like the following:

[branch "master"] remote = origin merge = refs/heads/master rebase = true 

Now, when you run git pull, it’ll rebase your local commits on top of the newly pulled-down commits instead of trying to merge them. Even better, try putting this in your global ~/.gitconfig file:

[branch] autosetuprebase = always 

With this change, all tracked branches from then on will be set up to rebase instead of merge.

Related Articles