Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I pull all remote changes with rebase instead of merge?

Tags:

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?

like image 704
michael Avatar asked Mar 14 '11 23:03

michael


People also ask

What is an alternative to merging in git rebasing?

While merging is definitely the easiest and most common way to integrate changes, it's not the only one: "Rebase" is an alternative means of integration.

Should I rebase instead of merge?

If you would prefer a clean, linear history free of unnecessary merge commits, you should reach for git rebase instead of git merge when integrating changes from another branch.

Does rebase affect remote?

No, locally rebasing doesn't change the remote.


1 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.

like image 94
Adam Dymitruk Avatar answered Sep 19 '22 15:09

Adam Dymitruk