git clone and checkout in a single command git clone and checkout in a single command git git

git clone and checkout in a single command


git clone u://r/l --branch x

still clones everything but sets the local HEAD to that branch so it's the one checked out.

Source:

--branch <name>
-b <name>
Instead of pointing the newly created HEAD to the branch pointed to by the cloned repository’s HEAD, point to <name> branch instead. In a non-bare repository, this is the branch that will be checked out. --branch can also take tags and detaches the HEAD at that commit in the resulting repository.


Is your problem the checkout being to large or the repository itself?As git clone, well, clones a repository you usually get the whole repository in its full size. (unless you are doing a shallow clone as you already suggested.)

If it's really about the checkout of the wrong branch git help clone says:

   --no-checkout, -n       No checkout of HEAD is performed after the clone is complete.

After cloning with -n you can manually check out


I was running into a same situation and it worked well with the Git Clone Command with --depth. And specify the branch-name/commit/Tag-Name at the end of the command with -b parameter.

Syntax:

git clone --depth 1 github.com:ORG-NAME/Repo.git -b <Branch-Name/Commit-Number/TAG>