Branching makes efficient ways for version management of code in any version management application like git, svn. Development in branching make process easier by splitting code in branches per modules. This article will help you to create a branch on remote Git repository.
Create Local Branch
First create branch on local git repository using following command. This command will create a branch named “stage1” and switch to it immediately.
Syntax: $ git checkout -b <BRANCH_NAME> Command: $ git checkout -b stage1
Push Branch to Remote
Now push newly created branch to remote Git repository. Branch will automatically created on remote git repository.
Syntax: $ git push <REMOTE_NAME> <BRANCH_NAME> Command: $ git push origin stage1
The above command creates branch on remote git repository with same name as local “stage1” and push all files there. If you want branch with different name on remote, use command as like below
Syntax: $ git push <REMOTE_NAME> <LOCAL_BRANCH_NAME>:<REMOTE_BRANCH_NAME> Command: $ git push origin stage1:development
This will create branch named “development” on remote git repository and push data from local branch “stage1”