0

可能重复:
使用 Git 和 Mercurial 进行部分克隆

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

是什么git clone url意思git 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
事实上,我的问题与仅克隆一个分支不同,尽管答案可能有点相似......

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

4

1 回答 1

1

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

于 2012-10-17T12:50:33.583 回答