I tried to search this question, but none of them answered my question.
Please let me give an example:
I get two branches in the git server
origin/master
origin/feature
Branch 'feature' is branched out from 'master', as everybody else is working on 'master', I don't want to impact them, so I branched out 'feature' in my local and pushed it to remote.
As there are commits every on 'master', two days later, I want to pull the least code on my 'feature', is there a way that I could just merge code from 'origin/master' to 'origin/feature', then just pull the least 'origin/feature'.
I tried
git checkout origin/feature
git merge origin/master
git status # you would see that this is the lease code with lots of commits
git checkout feature
git pull
But, after i git pull
, I got nothing, even those least commits are lost.
So I realized origin/feature
in local would be just an image of origin/feature
in remote. That's why my way didn't work.
The other way to meet my requirement is
git checkout feature
git stash
git pull origin master:feature
git push origin feature:feature # or just [git push]
git stash pop stash@{0}
And this is the way I use right now.
I'm wondering it there a way that I could just merge those two remote branches directly without pushing anything?