![]() # To be pedantic, also delete the local `master` branch since That one command is the equivalent of doing this: git clone Ĭd micronucleus # cd into the repo you just cloned The 2nd command ( git clone -b version_2.5 ) clones ALL REMOTE BRANCHES to your local PC, but then checks out the version_2.5 branch instead of the master branch. Let's assume that you have a remote repo on GitHub at, with remote branches master and version_2.5 (this is a real example you can actually run right now). Clone ALL remote branches, then `git checkout` the `branch_name`īut, I'd like to expound upon these two things a bit and show a more familiar set of equivalent commands so we can see what is happening with each under-the-hood. or some version of that, and a few which mention just:ĭownload all branches (withOUT the -single-branch part): # (We'll refer to this as "the 2nd command" below.) ![]() Git clone -b branch_name -single-branch \ _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) "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' '
0 Comments
Leave a Reply. |