Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change local branch remote origin to new one in GIT

Tags:

git

I checked out a branch let's call 1.14 from the remote 1.14 branch. I made local changes and made a commit, changed my local branch to something else, let's call mynew. If I run git branch -vv I see that

mynew efe918d [origin/1.14: ahead 1] commit_msg

Now I want to push this mynew not into the origin/1.14 but a new let's call origin/mynew, which isn't exist yet, I want to create it by pushing the local one.

How could I do this?

like image 296
ACs Avatar asked Jan 04 '23 11:01

ACs


1 Answers

You can specify the destination branch on push command

git push origin localBranch:remoteBranch

In your case you can write

git push origin mynew:mynew

If mynewdoesn't exist on the server, it will create it.

To set up mynew local branch to be linked (when pulling, pushing) to remote mynew branch use -u or --set-upstream equivalent option

git push -u origin mynew:mynew
like image 133
Flows Avatar answered Jan 07 '23 23:01

Flows