rebasing
If you pull remote changes with the flag --rebase
, then your local changes are reapplied on top of the remote changes.
git pull --rebase
merging
If you pull remote changes with the flag --merge
, which is also the default, then your local changes are merged with the remote changes. This results in a merge commit that points to the latest local commit and the latest remote commit.
git pull --merge
best practice
It is best practice to always rebase your local commits when you pull before pushing them. As nobody knows your commits yet, nobody will be confused when they are rebased but the additional commit of a merge would be unnecessarily confusing. Published commits are, however, usually merged, for example when branches are merged.
To avoid typing --rebase
whenever you pull you can config git to use it as default:
git config --global pull.rebase true