When working with code locally, you can use git pull rebase
to update your local code.
Rebasing with git pull
can be done by appending --rebase
to the CLI command.
git pull --rebase
It is recommended to set your global git config like so:
git config --global pull.rebase true
If you use the global setting, git pull
will always run with git pull --rebase
and git rebase whenever git pull
is run.
- git pull without rebase will create merge. Most of the time we don't want that.
- Merges are better kept at the PR merge at GitHub. Locally we shouldn't need to merge.
- Less polluted commits with git pull rebase.
- At PR we have to merge anyways.
Hence, without git rebase, you may get merge. So, as much as possible, try to use git rebase with pull locally.
Feel free to rebase on your own commits locally that are not shared.
Rule of thumb is rebase locally, but never rebase on remote.
We don't want to re-write git history on shared commits.