leftimage.blogg.se

Git clone branch from remote
Git clone branch from remote










git clone branch from remote
  1. #Git clone branch from remote full
  2. #Git clone branch from remote Pc
  3. #Git clone branch from remote plus

# Delete ALL other branches, including remote-tracking ones, which are not the That one command is the equivalent of doing this (in the end result at least, except that it also downloads much less data in the beginning since it only clones ONE branch NOT all of them): git clone The 1st command ( git clone -b version_2.5 -single-branch ) clones ONLY the version_2.5 branch to your local PC, and it also checks it out. I'm not an expert on this part, but I believe that's what +refs/heads/*:refs/remotes/origin/* means. You can see above that our git fetch command (which is also triggered by git pull since that is equivalent to git fetch & git merge) is configured to fetch ALL heads for ALL branches in the origin remote. git/config file to see them directly, or just run git config : $ git config We can also look at what our fetch references are.

#Git clone branch from remote plus

Here you can see our local branch version_2.5, which we are on, plus the locally-stored remote-tracking branches origin/HEAD (which points to origin/master), plus origin/master, and origin/version_2.5: $ git branch -a Git branch -a shows us that ALL branches, however, were cloned to our local PC. The -b version_2.5 part automatically checked out the version_2.5 branch for us instead of master. # your locally-stored remote-tracking branch, `origin/master` # it out with `git checkout master`, which would create it from # technically it won't exist yet since you haven't yet checked # 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 \

#Git clone branch from remote Pc

_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 branch from remote 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?".

git clone branch from remote git clone branch from remote

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 branch from remote

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)












Git clone branch from remote