Git how to create remote branch from checked out master
In a project you’ll reach at a certain point the need to start working on a new major version of your application, lets say version 2. Then you’ll probably want the current master to move to a branch with a name like “1.x” and from then on the master branch will contain version “2.x”.
To accomplish this, you’ll have to do some simple steps. I assume you already have a Git clone on your computer, go to the root directory of your clone and make sure you are in the master branch.
git branch -a
The branch with the “*” character before the name is the active one. Create a new branch “1.x” based on the master:
git checkout -b 1.x
A local branch 1.x should be created, you can check with “git branch -a”. The next command pushes the branch to the remote repository origin and tracks it.
git push -u origin 1.x
The branch exists now locally and in the remote Git repository. The active local branch is 1.x, check with “git branch -a”. If you want to work on the master branch again execute:
git checkout master