How to Git Clone a Specific Branch

While developing new code, it is always best practice to make a branch off of the Production, Development, or Test branch. Once this is done, you need to get those file to a location so that they can be developed on. You need to clone that branch!

Cloning the Branch

  • Open a terminal window. This example is based from Mac OS, but the same should be for Linux as well. We will be cloning from SSH.
  • Run the command syntax:
git clone -b branchName remoteRepository
  • for an example… assume the following:
    • branch name = mybranchDev
    • remote repository = git@github.com:teamA/project.git
    • The command would look like this…
git clone -b mybranchDev git@github.com:teamA/project.git

That’s it!

About Daniel Fredrick

Technology enthusiast, Programmer, Network Engineer CCIE# 17094

View all posts by Daniel Fredrick →

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.