Pete HoustonMay 22
Git move unpushed changes to a new branch
by Pete Houston
While coding, you will recognize that the current code should be developed under a different branch rather than main stream. So what would you do?
If you haven’t push the commits to server, then this is how to do it.
Assuming the code are on master, and you want to move to a new branch, develop, for example.
$ git checkout master
$ git checkout -b develop
$ git checkout master
$ git reset --hard origin/master
Now, all the development code is stored on develop branch, and master matches with origin/master.
Worry no more ☺