Clone only one branch [duplicate]

Question

I would like to know how I could clone only one branch instead of cloning the whole Git repository.

Answer

From the announcement Git 1.7.10 (April 2012):

  • git clone learned --single-branch option to limit cloning to a single branch (surprise!); tags that do not point into the history of the branch are not fetched.

Git actually allows you to clone only one branch, for example:

git clone -b mybranch --single-branch git://sub.domain.com/repo.git

Note: Also you can add another single branch or "undo" this action.

How to use git bisect?

How do I change the default location for Git Bash on Windows?