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?
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.
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.
No, locally rebasing doesn't change the remote.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With