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 ?
So what you're saying is you want to bring the changes from your master branch, into your dev branch? Switch to dev branch with a git checkout dev . Then git pull --rebase origin master . If you are lucky, there will be no conflicts and dev will have the latest changes from master.
Create a new branch with the branch, switch or checkout commands. Perform a git push with the –set-upstream option to set the remote repo for the new branch. Continue to perform Git commits locally on the new branch. Simply use a git push origin command on subsequent pushes of the new branch to the remote repo.
In case you are using the Tower Git client, pulling from a remote is very easy: simply drag the remote branch and drop it onto your current HEAD in the sidebar - or click the "Pull" button in the toolbar.
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. :)
One cool way to do this is to rebase origin/master into your remote branch. You can follow the following rebase workflow;
Check out to your local my_remote_feature branch and pull changes from that branch. git pull origin my_remote_feature
Do a git fetch
Then rebase origin/master like git rebase origin/master
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.
Merge the master
branch to your feature branch and then push the changes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With