DEV Community

Fernando Tricas García
Fernando Tricas García

Posted on

So, you want to create a git branch with your current code

Just for my reference: you have a set of changes that are getting bigger and bigger but you do not want to commit them to the master branch for ... reasons. So you decide to create a new branch and you are not sure about what to do. You can check How To Create A GIT Branch With Your Current Changes or you can follow (more or less the following steps).

  • Create the new branch in place:

    git checkout -b newbranch

  • Commit the changes (add things if you need):

    git commit -am"Some useful message"

  • Push the changes if you feel so inclined:

    git push --set-upstream origin newbranch

You can also reset the master branch, if you want:

git branch -f master origin/master

Top comments (0)