Facebook Twitter Instagram
    TecAdmin
    • Home
    • Ubuntu 20.04
      • Upgrade Ubuntu
      • Install Java
      • Install Node.js
      • Install Docker
      • Install LAMP Stack
    • Tutorials
      • AWS
      • Shell Scripting
      • Docker
      • Git
      • MongoDB
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    Home»GIT»How to Create a Branch in Remote Git Repository

    How to Create a Branch in Remote Git Repository

    RahulBy RahulSeptember 1, 20152 Mins ReadUpdated:October 7, 2020

    Branching makes efficient ways to manage versioning of your application code. The popular version management tools supported branches like Git, SVN etc. Development in branching make process easier by splitting code in branches per modules.

    Most of the Git providers (like: github.com, gitlab.com etc) provides option to create branch directly with web interface. But, in case you don’t have web interface access, You can also do the same by creating a branch in local repository and push changes to remote.

    This article will help you to create a branch on local repository and then push branch to the remote Git repository.

    Create A Local Git 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 
      

    You can created a branch on your local git repository. Use git branch command to view all the branches in local repository.

    Push Branch to Remote Git Repository

    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.

    You can also create branch on remote branch with other name. To create remote branch with other name speicify the remote branch branch name just after local branch name seprated with colon (:). The syntax and command looks 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”

    Conclusion

    In this tutorial, you have learned to create a branch on remote git repository.

    branch git
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp
    Previous ArticleHow to Upgrade CentOS 6.10 from CentOS 6.9-6.0
    Next Article How to Install LAMP (PHP 5.5, Apache 2.4 and MySQL 5.5) on Ubuntu 14.04 (Trusty Tahr)

    Related Posts

    How To Add a Git Remote Repository

    3 Mins Read

    How to Git Reset to Head

    Updated:November 3, 20213 Mins Read

    How to Delete a File on Git

    3 Mins Read

    How to Git Stash Changes

    Updated:October 29, 20213 Mins Read

    How to delete Git tags

    Updated:October 25, 20211 Min Read

    How to Create Git tags

    Updated:October 25, 20212 Mins Read

    Leave A Reply Cancel Reply

    Recent Posts
    • How to Install JAVA on Ubuntu 22.04
    • Switching Display Manager in Ubuntu – GDM, LightDM & SDDM
    • Changing the Login Screen Background in Ubuntu 22.04 & 20.04
    • How To Install PHP (8.1, 7.4 or 5.6) on Ubuntu 22.04
    • (Resolved) Please install all available updates for your release before upgrading
    Facebook Twitter Instagram Pinterest
    © 2022 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.