Git(hub): change branch?

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?

  • How to find whether a file is present in multiple branches in git
  • Master and topic branch both have changes
  • How do I extract and remove a merged branch in Git?
  • Git - move branch to master
  • How to perform merge?
  • How do you branch and merge with TortoiseSVN?
  • How do I git add only lines matching a pattern?
  • Why 'git log' is empty even if log file exists?
  • Changing an existing submodule's branch
  • Android - Add new library to repo?
  • Committing to master with detached HEAD
  • Cant push changes back to Launchpad using git-bzr
  • One Solution collect form web for “Git(hub): change branch?”

    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.

    Git Baby is a git and github fan, let's start git clone.