Git(hub): change branch?

0

Issue

I’ve forked a repo on github and then made a few changes on master branch.
But I made a mistake, I had to work on a new branch not on the master one.

Can I change branch or should I fork the master again, then make the branch and apply the changes I made?

Solution

Rename your local branch:

git branch -m master newbranch

Push it to your remote (let’s say myremote):

git push myremote newbranch

Create a master branch from github’s original remote (say origin):

git branch master origin/master

Forcefully push it:

git push myremote +master:master

This should do it.

Answered By – fge

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave A Reply

Your email address will not be published.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More