Reputation: 9684
When we do a fetch or pull and the local master branch is behind the origin/master branch or if the local master is on separate branch compared to origin/master, then how to bring local master in sync with origin/master?
https://git-scm.com/book/en/v2/images/remote-branches-3.png
Upvotes: 0
Views: 814
Reputation: 164859
You can perform the merge (or rebase) manually just like any other branch.
git fetch origin
git checkout master
git merge origin/master
0b743 < a6b4c < f4265 < 31b8e < 190a3 [origin/master]
\ \
< a38de < 893cf < abc123 [master]
Or you can use git pull origin master
which will git fetch origin
and git merge origin/master
for you same as above.
git checkout master
git pull origin master
Or you can avoid an unnecessary bookkeeping merge and replay your local changes on top of the remote ones with git pull --rebase
. This is a git fetch origin
plus a git rebase origin/master
.
git checkout master
git pull --rebase origin master
0b743 < a6b4c < f4265 < 31b8e < 190a3 [origin/master]
\
< a38de1 < 893cf1 [master]
Upvotes: 2