Reputation: 9641
I have a remote repository on github upstream
that is cloned of another github repository origin
. The origin
repository has several branches: master
, v1_x
, v2_x
. I'd like to fix a bug in v1_x
, and then forward port that change to the other branches v2_x
and master
.
How do I set up/create a branch in my local repository to track origin/v1_x
, and push to a feature branch upstream/my_awesome_bug_fix
?
Upvotes: 0
Views: 61
Reputation: 24458
To set up your branch to track origin/v1_x
:
git checkout -b my_awesome_bug_fix -t origin/v1_x
Then you can get updates from origin
with:
git pull
To push your branch to upstream
:
git push upstream my_awesome_bug_fix
I would probably keep it this way for clarity and explicitness of what's being sent where. But, if you want to be able to use both git pull
and git push
on your branch without specifying the remote, be sure you have push.default
set to "current", and add a push url to your origin remote:
git config push.default current
git remote set-url --push origin <upstream-url>
Now git pull
should fetch and merge changes from v1_x
on origin
, and git push
should push changes to my_awesome_bug_fix
on upstream
.
Upvotes: 1