怎么克隆非 branch 的源码? - V2EX
Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
luckypoem
V2EX    Linux

怎么克隆非 branch 的源码?

  •  
  •   luckypoem Aug 13, 2016 3860 views
    This topic created in 3560 days ago, the information mentioned may be changed or developed.
    hi.请教各位一个问题,这个地址 https://github.com/agbell/agbell.github.io/tree/hakyll 的内容怎么克隆下来?我只能成功运行 git clone https://github.com/agbell/agbell.github.io
    运行 git clone https://github.com/agbell/agbell.github.io/tree/hakyll 失败。
    11 replies    2016-08-15 09:28:37 +08:00
    owt5008137
        1
    owt5008137  
       Aug 13, 2016 via Android
    luckypoem
        2
    luckypoem  
    OP
       Aug 13, 2016
    @owt5008137 ,谢谢你
    snnn
        3
    snnn  
       Aug 13, 2016
    BTW ,不管你怎么 clone, 下载下来的都是所有 branch 。
    luckypoem
        4
    luckypoem  
    OP
       Aug 13, 2016
    标题写错了。应是:怎么克隆非 master 的源码?
    Hanxv
        5
    Hanxv  
       Aug 13, 2016 via Android
    你本地切换分支啊
    fatedier
        6
    fatedier  
       Aug 13, 2016
    先把项目直接 clone 下来,之后切换到那个分支, git checkout -b hakyll origin:hakyll
    smallpath
        7
    smallpath  
       Aug 13, 2016
    懒癌的话, 可以先 clone master 分支, 再在本地新建想要拉取的分支, 最后 pull 新建的分支
    shimanooo
        8
    shimanooo  
       Aug 13, 2016
    clone 之后,远程分支在本地会变成 origin/xxx 这样。
    然后 git 自动建立 master 分支,跟踪 origin/master 。
    zhaoace
        9
    zhaoace  
       Aug 14, 2016
    我来帮忙解释一下发生了什么吧。

    https://github.com/agbell/agbell.github.io/tree/hakyll 这个 link 里面
    1.「 https://github.com/agbell/agbell.github.io 」这个部分是 repo 的实际地址
    2. tree 代表是是个 folder ,如果是实际代码一般是 blob 表示是二进制文件。 比如 「 https://github.com/agbell/agbell.github.io/blob/master/about.html
    3. hakyll 是这个库的分支。

    所以你直接 clone 整个完整 url 是不行的。


    @owt5008137 是帮你 clone 了这个 repo 然后切换到了对应分支。
    「 git clone -b hakyll https://github.com/agbell/agbell.github.io

    你也可以分两步走:
    1. clone 整个库: git clone https://github.com/agbell/agbell.github.io
    2. 切换到对应分支 git check out hakyll


    另外如果你只想要代码,不想在 git 上花时间的话你可以 直接 download , 这样就直接 download 该 url 对应的分支的代码啦。
    adoyle
        10
    adoyle  
       Aug 15, 2016
    git clone 有 --single-branch 选项。可以不用下载所有分支。
    ilotuo
        11
    ilotuo  
       Aug 15, 2016 via Android
    git checkout origin/xxxx
    git checkout myxxx
    git commit
    About     Help     Advertise     Blog     API     FAQ     Solana     1211 Online   Highest 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 67ms UTC 23:37 PVG 07:37 LAX 16:37 JFK 19:37
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86