How to Create a Branch in Remote Git Repository


In any Version Management, Branching is a efficient way to manage code version management application like git, svn. In development environment, branching make process easier by splitting code in branches as per modules.Below blog post article will help you to create a branch on remote Git repository.

 


Create Local Branch


First We are going to create branch on local git repository using below command and  below command will create a branch named “Phase1” and switch to it immediately.

Syntax:
$ git checkout -b <BRANCH_NAME>

Command:
$ git checkout -b Phase1

 


Push Branch to Remote

When we push newly created branch to remote Git repository then branch will automatically created on remote git repository.

Syntax:
$ git push <REMOTE_NAME> <BRANCH_NAME>

Command:
$ git push origin Phase1

The above command creates branch on remote git repository with same name as local “Phase1”
and push all files there. If you want to create branch with different name on remote, use below command:-

Syntax:
$ git push <REMOTE_NAME> <LOCAL_BRANCH_NAME>:<REMOTE_BRANCH_NAME>

Command:
$ git push origin Phase1:TestDevModule

Above command will create branch named “TestDevModule” on remote git repository and push data from local branch “Phase1”


 

Leave a Reply

Your email address will not be published. Required fields are marked *