远程分支机构是否克隆到本地git仓库?

时间:2012-10-17 10:50:48

标签: git git-branch git-clone git-commands

  

可能重复:
  Partial clone with Git and Mercurial

如果我只想克隆一个分支,我该怎么做?

git clone urlgit clone url --all是什么意思?

[hugemeow@home base]$ git branch
* master
[hugemeow@home base]$ git branch -a
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/donut-release
  remotes/origin/donut-release2
  remotes/origin/eclair-passion-release
  remotes/origin/eclair-release
  remotes/origin/eclair-sholes-release
  remotes/origin/eclair-sholes-release2
  remotes/origin/froyo
  remotes/origin/froyo-release
  remotes/origin/gingerbread
  remotes/origin/gingerbread-mr4-release
  remotes/origin/gingerbread-release
  remotes/origin/ics-factoryrom-2-release
  remotes/origin/ics-mr0
  remotes/origin/ics-mr0-release
  remotes/origin/ics-mr1
  remotes/origin/ics-mr1-release
  remotes/origin/ics-plus-aosp
  remotes/origin/jb-dev
  remotes/origin/jb-mr0-release
  remotes/origin/jb-release
  remotes/origin/master
  remotes/origin/tools_r20



[mirror@home base]$ git branch -r
  origin/HEAD -> origin/master
  origin/donut-release
  origin/donut-release2
  origin/eclair-passion-release
  origin/eclair-release
  origin/eclair-sholes-release
  origin/eclair-sholes-release2
  origin/froyo
  origin/froyo-release
  origin/gingerbread
  origin/gingerbread-mr4-release
  origin/gingerbread-release
  origin/ics-factoryrom-2-release
  origin/ics-mr0
  origin/ics-mr0-release
  origin/ics-mr1
  origin/ics-mr1-release
  origin/ics-plus-aosp
  origin/jb-dev
  origin/jb-mr0-release
  origin/jb-release
  origin/master
  origin/tools_r20

编辑1
事实上,我的问题与Clone only one branch不同,尽管答案可能有点类似......

顺便说一句,如果该链接是解决方案,在从远程仓库克隆之前,如何获取分支列表? (该链接中未提及此问题,如果该链接可以回答我的问题,则应该预先解决此问题。)

1 个答案:

答案 0 :(得分:1)

您可以在使用git ls-remote --heads <repo-url>克隆之前获取分支列表。