Rebase by default when doing git pull
If you want git to do a rebase instead of a merge when pulling you can run git pull like this:
git pull --rebase
Instead of typing the above (or making an alias for it), you can tell git to automatically rebase when pulling.
In git >= 1.7.9:
git config --global pull.rebase true
In git < 1.7.9:
git config --global branch.autosetuprebase always
The latter has the effect of automatically adding branch.<name>.rebase true
for each checked out local branch that is tracking an upstream branch to the repository config file.
Note that if you have both options set (not really recommended) then branch.<name>.rebase true
that is automatically added for each branch takes precedence over global pull.rebase true
.
Written by Marcin Kulik
Related protips
4 Responses
Would you mind explaining the benefit of the rebase? Just to keep the commit log cleaner?
ready4god2513: here's a nice write-up on the topic: http://mislav.uniqpath.com/2013/02/merge-vs-rebase/
Hmm, why --global? You might not want to let this affect your work in all repos.
There's another reason to always do rebasing pulls --- to avoid foxtrot merges! http://bit-booster.blogspot.ca/2016/02/no-foxtrots-allowed.html