How to pull from a remote branch `someBranch` to a local branch `sonOfSomeBranch`?

Viewed 24

So, my teammate and I have these branches: master, someBranch and sonOfSomeBranch. The last one, as you might have guessed, was branched off someBranch. I have all of them both locally and remotely, tracked.

I have pushed code to my sonOfSomeBranch, but my teammate also did some work on the someBranch in the meantime. Now I want to pull what she has done into my sonOfSomeBranch.

Can this be done, and if yes, how? I only thought of pulling her code from someBranch and adding it manually to sonOfSomeBranch, but there has to be a smarter solution.

1 Answers

Pull someBranch and merge it into sonOfSomeBranch:

git checkout sonOfSomeBranch
git fetch origin someBranch:someBranch
git merge someBranch
git push origin sonOfSomeBranch

Or pull someBranch and rebase sonOfSomeBranch on top of it:

git fetch origin someBranch:someBranch
git rebase someBranch sonOfSomeBranch
git push --force origin sonOfSomeBranch
Related