According to the git documentation, git clone creates remote-tracking branches for each branch in the cloned repository . However, today I was setting up a new machine image on Ubuntu 14.04, and in the process upgraded my git from 1.7.9.5 to 2.0.2. When I was attempting to use capistrano to deploy code from a different (non-master) branch to the box, it was failing, and I tracked down the root cause to the issue that git clone --depth 1
(the command that cap generated and uses) was not creating remote tracking branches for each branch. As a result, attempting to reference a checkin from said non-master branch failed. I did a
git branch -r
And saw that only
origin/HEAD -> origin/master
origin/master
Were shown, not all of my other branches too.
I see that there were some behavior changes introduced in git 1.9 , also referenced on SO here .
Can someone explain why this change causes the behavior I am now seeing, and what the command is that I would need to now execute to get this working as it did under git 1.7?
Thanks!
From the doc for git clone :
--[no-]single-branch
Clone only the history leading to the tip of a single branch, either specified by the
--branch
option or the primary branch remote's HEAD points at.When creating a shallow clone with the
--depth
option, this is the default, unless--no-single-branch
is given to fetch the histories near the tips of all branches.
Not knowing much about capistrano, are you able to get it to clone with the --no-single-branch
option or omit the shallow clone --depth
option? or get it to clone the desired branch only using the --branch
option?
As you were on 1.7.9.5 previously, you did not see this behaviour since it was 1.7.10 that introduced the single-branch option to git clone
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.