git clone single branch repository

How to Clone Single Branch in Git

Typically, when you clone a git repository, it will clone all branches in the repository. But sometimes you may need to clone just a single branch from your remote repository. In this article, we will learn how to clone single branch in git.

How to Clone Single Branch in Git

You can clone a single git branch, with the following command. Replace <url> with the URL for git repository. It will clone the master branch for you.

$ git clone <url> --single-branch

If you want to clone a different branch, you can use the following command instead. Replace <url>, <branch>,<folder> with the repo URL, git branch to cloned, and local folder respectively.

$ git clone <url> --branch <branch> --single-branch [<folder>]

In this short article, we have learnt how to clone single branch in git.

Also read:

How to Ignore Git File Permission Changes
How to Configure Line Endings in Git
Git Remove File from Commit History
Bash Loop Through Files in Directory Recursively
How to Remove .pyc File from Git Repository

Leave a Reply

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