jviotti jviotti - 1 year ago 234
Git Question

Push commits to another branch

Is it possible to commit and push changes from one branch to another.

Assume I commited changes in BRANCH1 and want to push them to BRANCH2.

From BRANCH1, is it valid to do:

git push origin **BRANCH2**

And then reset BRANCH1?

Answer Source

That will almost work.

When pushing to a non-default branch, you need to specify the source ref and the target ref:

git push origin branch1:branch2


git push <remote> <branch with new changes>:<branch you are pushing to> 
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download