如果一个git fetch被取消了一半,它会恢复吗? [英] If a git fetch is cancelled half way will it resume?

查看:1071
本文介绍了如果一个git fetch被取消了一半,它会恢复吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有时候取得任何git仓库(通过执行 git fetch repository_URL )可能需要几个小时,这取决于仓库的大小和网络速度。

如果由于某种原因,用户取消中间获取方式,然后尝试在稍后取回同一个存储库时,在他/她取消最后一次获取的完全相同的环境中,

它会在什么地方重新开始获取?

解决方案

不,git clone / fetch / pull操作不具备恢复功能。



唯一的选择是 rel =nofollow noreferrer>在此主题中提及 gitolite (这是一个管理ACM的perl脚本 - 用于回购的访问控制级别,以及提供其他公用事业围绕着Git访问)


gitolite可以配置为更新一个Git bundle(请参阅​​
HTTP协议进行下载,然后使用rsync进行下载支持恢复的
HTTP客户端的客户端。

使用这种技术可以使下载所有内容和从下载的东西中制作回购步骤截然不同,并且第一步可以使用任意数量的尝试。



缺点很明显:


  1. 这需要服务器端的特殊设置。

  2. 目前还不清楚如果有人在下载软件包时更新存储库
    ,或者相邻下载尝试之间的更新发生
    ,会发生什么情况。







关于<$ c的可恢复特征$ c> git clone / fetch (在如何在一个不稳定的连接上完成一个大项目的git克隆?),那里是最近关于 git邮件列表的讨论(2016年3月) p>


  • 一种方法是服务器生成捆绑包,可以加载(使用> wget -c !)并添加到本地repo中(因为一个bundle是一个可以克隆的文件,就像它是一个git仓库)。

    请参阅 a href =https://kernel.org/cloning-linux-from-a-bundle.html =nofollow noreferrer>从软件包中克隆Linux



即:

  wget -c https:// cdn。 kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/clone.bundle 
git bundle verify clone.bundle
...
clone.bundle没问题
git clone clone.bundle linux
#现在,将原点指向活动git存储库并获取最新更改:
cd linux
git remote删除原始
git远程add origin https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git pull origin master

$ ul
  • 另一种方法是可恢复的 git clone 在此主题中讨论




  • 我们可以通过混合使用
    智能和愚蠢的HTTP协议来实现可恢复的克隆。



    1. 最终调用 git clone 传输层和
      git-remote-cur l 将探测info / clone URL;如果资源
      无法加载,则所有事情都会通过传统的代码路径。 git-remote-curl code>检测到愚蠢克隆的支持,它会执行
      重试直到成功下载完整的包数据在内部跳舞
      ,暂时更新远程跟踪参考,然后
      假装就好像它被要求做增量提取一样。如果这
      没有任何 die()成功,那么每个人都很高兴。

    2. 因为某些原因(包括
      不耐烦碰到 CTRL C ),必须 die()) ,保留 $ GIT_DIR ,下载 .info 文件并部分下载 .pack file。

      告诉用户可以恢复克隆以及如何恢复。



    请注意,这是一个可恢复的克隆, 不是可恢复的抓取


    初始克隆和后续的增量提取是正交问题。



    由于拟议的克隆更新比
    有更大的回报, fetch,即


    • 传输的数据量要大得多,h ence
      在恶劣的网络环境中网络超时的可能性是
      高得多,需要恢复得大得多。

    • 不仅该方法使得clone可恢复并帮助
      的客户,它可以帮助服务器减少批量转移到CDN。


    它的损坏小得多现有的代码,即


    • 我们没有必要悲观化打包过程,只抛弃
      生成的大部分字节,就像提议的方法
      为fetch一样。
    • 需要的区域新代码是很好的隔离,并且切换到
      新协议在交换中很早发生无需向现有代码路径共享
      代码;这些属性使得
      引入回归的风险更小。


    只有在新协议中才有,在v2协议中有提议让双方在ref广告之前交换能力。然后,客户端看到了服务器的可恢复URL,知道是否继续进行广告。

    请参阅 stefanbeller / gitprotocol2-10 其中准备好了。


    Sometimes fetching any git repository ( by executing the "git fetch repository_URL") might take many hours depending the size of repository and network speed.

    If for some reason the user cancels the fetch mid way and then tries to fetch the same repository later on, in exactly same environment where he / she cancelled the last fetch, how does the fetch is going to work?

    Will it resume the fetch where it left off?

    解决方案

    No, git clone/fetch/pull operations don't have a "resume" capability.

    The only alternative, mentioned in this thread, is gitolite (which is a perl script managing ACM -- Access Control Level for your repo, as well as providing other utilities around git access)

    gitolite can be configured to update a "Git bundle" (see the git-bundle manual) which is then can be made downloadable via rsync or HTTP protocols and then it can be downloaded using an rsync client of a HTTP client which supports resuming.

    Using this technique can make the "download everything" and "make a repo out of the downloaded stuff" steps distinct, and the first step can be carried out using any number of attempts.

    The downsides are obvious:

    1. This requires special setup on the server side.
    2. It's unclear what happens if someone manages to update a repository while someone is downloading its bundle, or the update happens between the adjacent download attempts.


    Regarding the resumable feature of git clone/fetch (mentioned in "How to complete a git clone for a big project on an unstable connection?"), there is a recent discussion (March 2016) on the git mailing list.

    • One approach consists for the server to produce bundles, that can be loaded (with resume using wget -c!) and added to the local repo (since a bundle is one file you can clone from, as if it was a git repo).
      See "Cloning Linux from a bundle"

    That is:

    wget -c https://cdn.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/clone.bundle
    git bundle verify clone.bundle
    ...
    clone.bundle is okay
    git clone clone.bundle linux
    #Now, point the origin to the live git repository and get the latest changes:
    cd linux
    git remote remove origin
    git remote add origin https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
    git pull origin master
    

    We could implement resumable clone by making a bit of a hybrid of the smart and dumb HTTP protocol.

    1. A git clone eventually calls into the transport layer, and git-remote-curl will probe for the info/clone URL; if the resource fails to load, everything goes through the traditional codepath.

    2. When git-remote-curl detects the support of dumb clone, it does the "retry until successfully download the pack data fully" dance internally, tentatively updates the remote tracking refs, and then pretends as if it was asked to do an incremental fetch. If this succeeds without any die(), everybody is happy.

    3. If the above step 3. has to die() for some reason (including impatience hitting CTRLC), leave the $GIT_DIR, downloaded .info file and partially downloaded .pack file.
      Tell the user that the cloning can be resumed and how.

    Note that is is for a resumable clone, not a resumable fetch:

    the initial "clone" and subsequent incremental "fetch" are orthogonal issues.

    Because the proposed update to "clone" has much larger payoff than the proposed change to "fetch", i.e.

    • The amount of data that gets transferred is much larger, hence the chance of network timing out in a poor network environment is much higher, need for resuming much larger.
    • Not only the approach makes "clone" resumable and helping clients, it helps the server offload bulk transfer out to CDN.

    and it has much smaller damage to the existing code, i.e.

    • We do not have to pessimize the packing process, only to discard the bulk of bytes that were generated, like the proposed approach for "fetch".
    • The area new code is needed is well isolated and the switch to new protocol happens very early in the exchange without sharing code to existing codepath; these properties make it less risky to introduce regression.

    To avoid an HTTP-only feature in the new protocol, there is proposal for the "v2" protocol that would let the two sides exchange capabilities before the ref advertisement. Then the client, having seen the server's resumable URL, knows whether or not to proceed with the advertisement.
    See stefanbeller/gitprotocol2-10 which is up for grabs.

    这篇关于如果一个git fetch被取消了一半,它会恢复吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆