Reputation: 288
Let's say I'm working on a branch XYZ and someone else pushes some changes in the main branch, How do I get the latest changes to my branch XYZ? I switched to dev branch and got the latest pull but when I go back to my branch XYZ I don't get the recent changes that I get in the Dev branch.
Upvotes: 2
Views: 119
Reputation: 1123
It is possible to do so even without switching branches. Switching is slow if there are a lot of new changes on dev. Be careful though - with this process you have to be sure you pushed all the local hanges you previously made on dev.
# get latest commit from dev branch whilst still being on XYZ
git fetch origin dev:dev
# merge those changes
git merge dev
Upvotes: 0
Reputation: 323
You have to merge your dev
branch into your branch XYZ
like this:
git checkout dev
git pull origin dev
# to get your branch up to date with the remote
git checkout XYZ
git pull origin XYZ
# to get your branch up to date with the remote
git merge dev
# this will merge your dev branch into your branch XYZ.
# there could be possible "merge conflicts" resolve it.
Upvotes: 0
Reputation: 2367
You'll have to do this
git checkout xyz
git pull origin xyz
git merge main_branch
Upvotes: 0
Reputation: 1329592
If you have not pushed yet your branch XYZ, assuming that XYZ was created from dev:
git checkout dev
git pull
git checkout XYZ
git rebase dev
That will replay your local commits on top of the updated dev.
If XYZ was alreay pushed, then it is more prudent to do a simple merge.
git checkout XYZ
git merge dev
Upvotes: 5