


_No other remote branches will be cloned to your PC # means that ONLY `branch_name` is cloned, fetched, pulled, and Clone ONLY `branch_name`, then check it out. There are ample answers here which mention:ĭownload 1 branch ( with the -single-branch part): # (We'll refer to this as "the 1st command" below.) Pipe -single-branch through the submodule helper framework to make it to ' clone' later on. Previously, performing " git clone -recurse-submodules -single-branch" resulted in submodules cloning all branches even though the superproject cloned only one branch. (Merged by Junio C Hamano - gitster - in commit b22db26, ) clone: pass -single-branch during -recurse-submodules See commit 132f600, commit 4731957 () by Emily Shaffer ( nasamuffin). With Git 2.26 (Q1 2020), " git clone -recurse-submodules -single-branch" now uses the same single-branch option when cloning the submodules. The magic line for getting missing branches to reverse -single-branch is (git v2.1.4): git config +refs/heads/*:refs/remotes/origin/*

Git config refs/heads/*:refs/remotes/origin/* # for getting back all the branches (see Peter Cordes' comment)
GIT CLONE A REMOTE BRANCH FULL
"Undoing" a shallow clone is detailed at " Convert shallow clone to full clone" (git 1.8.3+) # unshallow the current branch See more at " Is git clone -depth 1 (shallow clone) more useful than it makes out?". This makes git clone -depth 1 the easiest way to save bandwidth.Īnd since Git 1.9.0 (February 2014), shallow clones support data transfer (push/pull), so that option is even more useful now. This is implicit when doing a shallow clone. Git clone -single-branch "file://$(pwd)/." singlebranch You can see it in t5500-fetch-pack.sh: test_expect_success 'single branch clone' ' is the local folder where you want to clone the repository.is the URL of the remote repository, and does not reference the branch cloned.Note: the git1.7.10 (April 2012) actually allows you to clone only one branch: # clone only the remote primary HEAD (default: origin/master)
