You are currently viewing How to clone and fetch a specific git branch

How to clone and fetch a specific git branch

Sharing is caring!

Here is the easy way to clone a specific git branch in a local machine.

  1. First clone repository.
git clone <repository_url>
  1. List all branches.
git branch -a 
  1. Checkout the branch that you want to clone.
git checkout <name_of_branch>
  1. After that apply the following commands to execute pulls and pushes without having to specify the target branch.
git branch --set-upstream-to=origin/<branch> <local_branch>

Keywords: clone specific branch.

Sharing is caring!

Leave a Reply