V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
git
Pro Git
Atlassian Git Tutorial
Pro Git 简体中文翻译
GitX
whileFalse
V2EX  ›  git

git clone 可以仅拉取指定提交吗

  •  
  •   whileFalse · Apr 15, 2017 · 7040 views
    This topic created in 3299 days ago, the information mentioned may be changed or developed.

    每次构建都是用 git clone ,随着历史版本越来越大也就越来越慢。

    最近发现有 --depth 1 这种用法,刚激动了一下,忽然想起来我每次并不是构建 head 啊。

    9 replies    2019-03-28 18:33:58 +08:00
    zhs227
        1
    zhs227  
       Apr 15, 2017
    构建不应该是用 git pull 么,为什么会用 clone 呢
    只有库不存在的时候才需要 clone 。都是历史数据, pull 的结果也是精确可信的
    whileFalse
        2
    whileFalse  
    OP
       Apr 15, 2017
    自己回答,可以拉指定分支,但不能是提交。

    git clone -b mybranch --single-branch --depth 1
    miaotaizi
        3
    miaotaizi  
       Apr 15, 2017 via iPhone
    克隆下来再切换分支不行嘛?
    coderfox
        4
    coderfox  
       Apr 15, 2017 via Android
    构建别人的应用可以在原来的仓库 git pull ,没必要重新 clone 。
    whileFalse
        5
    whileFalse  
    OP
       Apr 15, 2017
    @zhs227 @coderfox 因为某种历史原因目前用的 clone 。改成 pull 稍微费点劲

    @miaotaizi 这不是嫌历史代码太多么。尤其是前端代码,放一堆过时的图片什么的。
    xlvecle
        6
    xlvecle  
       Apr 15, 2017
    @whileFalse 具体描述下?觉得这个历史原因很神奇,想看看是多么邪门儿的 git workflow
    crysislinux
        7
    crysislinux  
       Apr 16, 2017 via Android
    用 clone 构建也很正常吧,比如每次构建的服务器都是同样的环境,并不会保存上次的 clone
    Arthur2e5
        8
    Arthur2e5  
       Apr 17, 2017
    有没有想过加 tag 呢? git clone 的 -b 也可以是 tag 的呢。
    AngryPanda
        9
    AngryPanda  
       Mar 28, 2019
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1528 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 44ms · UTC 16:47 · PVG 00:47 · LAX 09:47 · JFK 12:47
    ♥ Do have faith in what you're doing.