goutham_kgh
goutham_kgh

Reputation: 167

Git pull master into remote branch on origin

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 ?

Upvotes: 5

Views: 18013

Answers (3)

Ryan
Ryan

Reputation: 443

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. :)

Upvotes: 8

Olalekan Sogunle
Olalekan Sogunle

Reputation: 2357

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.

Upvotes: 2

René Höhle
René Höhle

Reputation: 27325

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

Upvotes: 1

Related Questions