How do I shallow clone a repo on a specific branch?
Asked Answered
T

1

104

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.

Tabanid answered 17/2, 2014 at 16:7 Comment(0)
T
180

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

Tabanid answered 17/2, 2014 at 16:7 Comment(3)
You can use --no--single--branch instead -b bar, to download first commit form ALL branches.Malemute
I think you mean --no-single-branch and not --no--single--branch.Spar
The more verbose version of -b is --branchArium

© 2022 - 2024 — McMap. All rights reserved.