Close and Go BackBack to Viget

Only You Can Prevent git Merge Commits

Clinton R. Nixon
Clinton R. Nixon, Former Staffer, February 12, 2010

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.

blog comments powered by Disqus

We're the Developers

at Viget Labs. We write about web development trends, tips, best practices, industry events, and our projects — all with an emphasis on Ruby on Rails.

Contact Us

Have any questions, comments, ideas, or secrets to share? Let us know.


How many minutes in an hour?

Sorry, you need to have Javascript enabled to use this form. (Don't blame us, blame the spammers!) If you'd like to contact us, please visit our Contact page.