How to Create a Branch in Remote Git Repository

undefined

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

If You Appreciate What We Do Here On Mimastech, You Should Consider:

  1. Stay Connected to: Facebook | Twitter | Google+
  2. Support us via PayPal Donation
  3. Subscribe to our email newsletters.
  4. Tell other sysadmins / friends about Us - Share and Like our posts and services

We are thankful for your never ending support.

Leave a Reply

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