Git: Rebase on Pull by Default

I was a bit surprised today when git presented me a merge message window after i did a pull. This should not happen as the normal behavior here should be to rebase the changes. But apparently that didn’t happen this time. When i asked one of the other dev ‘s what could be the issue. We quickly figured out i was just missing some config entry in .git/config. This probably happened some time ago when i did a fresh checkout.

So to make sure rebasing is done by default. You can run a simple git command or modify the .git/config file manually.

In git >= 1.7.9

git config –global pull.rebase true

In git < 1.7.9

$ git config branch.autosetuprebase always

or do

$ vi .git/config

Make sure [branch “master”] has rebase set to true. It should look like the snippet below.

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

Starting to really like git. A couple of more quirks and things will be running fine.

comments powered by Disqus