How do I shallow clone a repo on a specific branch?

GitContinuous IntegrationGit BranchGit CloneShallow Clone

Git Problem Overview


How do I shallow clone a git repository, so that my clone contains only 1 history item, and starts on a specific branch?

I know how to do a shallow clone:

git clone --depth 1 https://path/to/myrepo.git

but not start the clone on a specific branch.

Git Solutions


Solution 1 - Git

To clone repo foo.git with branch bar do:

git clone --depth 1 https://path/to/repo/foo.git -b bar

See the git-clone documentation: https://www.kernel.org/pub/software/scm/git/docs/git-clone.html

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionjoseph.hainlineView Question on Stackoverflow
Solution 1 - Gitjoseph.hainlineView Answer on Stackoverflow