I can pull changes using git pull
, but it merges my local commits. Is there a git rebase
equivalent with which I can pull in remote changes?

- 124,556
- 26
- 146
- 141

- 106,540
- 116
- 246
- 346
-
1Related: [How to make Git pull use rebase by default for all clones?](http://stackoverflow.com/q/13846300/456814). – May 23 '14 at 19:05
4 Answers
Yes you can git pull --rebase
.
You can also set that to be the default pull behaviour when you track a branch with git config branch.autosetuprebase always
. Replace "always" with "remote" or "local" if you want to do it to those specific types of branches that you're tracking.
Now all you have to do is git pull
.
If for some reason you want to do a merge, you can do git pull --no-rebase
.
Hope this helps.
UPDATE: see comments below for how to do this on existing branches.

- 124,556
- 26
- 146
- 141
-
8`branch.autosetuprebase` only changes the default pull “mode” for *new* branches that have an upstream to track. `branch.
.rebase` is the variable that controls the operation for an individual branch (it is set to true for new “tracking” branches if `branch.autosetuprebase` is true when the branch is created). Use `git config branch. – Chris Johnsen Mar 15 '11 at 03:26.rebase true` to set it manually for a single branch. -
correct. I forgot to mention the existing tracking branches. You can also edit the config by hand if you know what you're doing. – Adam Dymitruk Mar 15 '11 at 03:47
-
1To do it be editting the config file, find the section for the branch and add: rebase = true – phorgan1 Sep 27 '12 at 21:08
-
Also add a --global flag to apply it to the global git config and not just the repository: git config --global branch.autosetuprebase always – codingFoo Oct 30 '12 at 15:33
-
3you can also set "rebase = True" in the [pull] section of your .gitconfig. – dbn Jun 20 '13 at 19:10
-
@dbw that's useful if you are already tracking branches and they are merging. – Adam Dymitruk Jun 20 '13 at 22:21
-
`git config branch.autosetuprebase always` will only rebase while updating the local tracking branch when doing `git pull` and otherwise do normal merges when merging from one branch to other. Is that correct understanding? – IsmailS May 28 '14 at 04:32
-
Instead of autosetuprebase
, you can use the pull.rebase
config option to change the behavior for every git pull
(instead of only newly-created branches):
[pull]
rebase = true
The difference is this will apply to non-tracking branches and any branches you had set up before enabling autosetuprebase
. So if you really want pull --rebase
to always be the default, pull.rebase
is the way to go!

- 6,679
- 3
- 33
- 60

- 2,487
- 1
- 22
- 27
-
@Bohdan true...I gave up on TortoiseGit for every day use a long time ago, if you want to do anything tricky with git you end up having to go to the command line anyway. – Jay Paroline Jul 15 '14 at 02:33
-
I usually use a fetch/rebase combination so my current (local) work stays at the top:
git fetch
git rebase origin/develop

- 92,053
- 36
- 243
- 426
To change default behavior from merge
to rebase
In git >= 1.7.9:
git config --global pull.rebase true
remove global if you want to apply for current repo only

- 6,808
- 3
- 37
- 47