Bostonian
Bostonian

Reputation: 687

Push specific commit a remote branch

I set up a local branch which tracks remote/mainline and made some changes to this local branch.

Besides git push to push the changes to remote/mainline, could I also push these changes to remote/mainline2 without setting additional local branch tracking remote/mainline2?

Upvotes: 0

Views: 139

Answers (3)

Toby
Toby

Reputation: 76

You can do git push origin [branchNameHere] or ggpush if you use ohmyzsh (does the same thing)

Or if you want to continue to push to that branch and not need to go ggpush, just do git branch -u [branch] [--set-upstream works too]

Upvotes: 0

jbaptperez
jbaptperez

Reputation: 706

If your local branch name is mainline:

git push remote mainline:mainline2

This is an explicit push which indicates the local source branch and the remote targeted one. It creates the remote branch if the one does not exist.

Upvotes: 1

EncryptedWatermelon
EncryptedWatermelon

Reputation: 5598

You can push to any branch you want

To push HEAD

git push origin HEAD:MY_FUN_NEW_BRANCH

To push a specific branch

git push origin mainline:mainline2

Upvotes: 1

Related Questions