5

I have a two remote branches: origin/master and origin/my_remote_feature

I have checked out my_remote_feature using git checkout --track -b origin/my_remote_feature

There are a couple of changes made in master that I want to pull into my branch that tracks the remote branch. How do I go about it ?

goutham_kgh
  • 167
  • 1
  • 1
  • 10
  • 2
    Possible duplicate of [Get changes from master into branch in git](http://stackoverflow.com/questions/5340724/get-changes-from-master-into-branch-in-git) – Edward Jan 19 '16 at 16:53

3 Answers3

8
git rebase origin/master

Is all you really need to do. then resolve any conflicts. You might need

git rebase --continue

if there are are conflicts. This will put my_remote_feature commits on top of the HEAD of origin/master. Re-writing history as it were.

git merge origin/master

Is also a possibility. However, you will find that all the commits to master will become part of your remote_feature commit history. Which you may not want. Generally rebase is better to keep your commit history pristine. :)

Ryan
  • 436
  • 5
  • 15
2

One cool way to do this is to rebase origin/master into your remote branch. You can follow the following rebase workflow;

  1. Check out to your local my_remote_feature branch and pull changes from that branch. git pull origin my_remote_feature

  2. Do a git fetch

  3. Then rebase origin/master like git rebase origin/master

  4. If all works successfully, push your new updates. git push origin my_remote_feature

This will bring all the changes on master on top of your changes in my_remote_feature. If there are any conflicts, you will have to resolve them along the way and make sure you add files after resolving conflicts then do a git rebase --continue after every conflict resolutions.

You can refer to the git rabase doc for more information.

Olalekan Sogunle
  • 2,299
  • 1
  • 20
  • 26
1

Merge the master branch to your feature branch and then push the changes.

René Höhle
  • 26,716
  • 22
  • 73
  • 82