第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

更新 git repo 所需的最少網(wǎng)絡流量是多少?

更新 git repo 所需的最少網(wǎng)絡流量是多少?

蝴蝶刀刀 2022-06-28 17:34:23
git很慢,讓我們自動化上下文是我想編寫一個更新約 150 個 git 存儲庫的腳本。與我們之前的 subversion 安裝相比,Gitlab/hub 在網(wǎng)絡上的速度幾乎慢了一個數(shù)量級,例如:(dev) go|c:\srv\lib\examradar> python -c "import time;start=time.time();import os;os.system('svn up');print time.time() - start"Updating '.':At revision 31294.0.559000015259(dev) go|c:\srv\lib\code\dkrepo> python -c "import time;start=time.time();import os;os.system('git pull');print time.time() - start"Already up to date.Current branch master is up to date.4.31999993324IE。150 個 svn 存儲庫至少需要 84 秒,而 150 個 git 存儲庫將需要 10 分鐘以上(?。ㄔ?win10 上的 wsl 上的 ubuntu 中運行相同的命令會產(chǎn)生 0.48 秒和 1.52 秒——看圖 ;-)使用腳本,我們可以并行執(zhí)行所有“簡單”更新,并將 git-case 縮短到約 100 秒。不幸的是,我們遇到了超時(經(jīng)常這樣做git rev-parse @{u}),所以我正在尋找最有效的方法來更新 git repo 并善待 git 服務器。我對“作弊”持開放態(tài)度,例如,如果在 git 之外有辦法知道(很有可能)不需要更新 repo(webhooks?,后臺 fetch-daemons?)搞砸回購是非常具有破壞性的,所以如果拉動會產(chǎn)生合并沖突,它應該保釋。當前代碼我正在使用 python 調(diào)用包來簡化調(diào)用命令。我也會對只使用原始 git 命令的答案感到滿意。這是我到目前為止...首先是一個便捷函數(shù),它打印正在運行的命令及其輸出,并將輸出作為字符串返回:from invoke import taskdef runner(c):    return lambda cmd: c.run(cmd, hide=False, echo=True).stdout.strip()然后是獲取回購狀態(tài)的任務/功能。我相信只有git fetch和 git rev-parse @{u}` 接觸網(wǎng)絡(?):@taskdef get_status(c, wc):    """Return a set containing the strings          local-clean     if there are no local changes          local-dirty     if there are local changes          untracked       if there are files that haven't been added to git          remote-change   if upstream has changed          local-change    if there are local committed (but not pushed) changes          diverged        if local and upstream have diverged    """    run = runner(c)    with c.cd(wc):        status = []        porcelain = run('git status --porcelain')        if porcelain == "":            status.append('local-clean')        else:            status.append('local-dirty')        untracked = run('git ls-files --others --exclude-standard')        if untracked:            status.append('untracked')        run('git fetch')    # only interested in current branch so not using `git remote update`
查看完整描述

1 回答

?
一只甜甜圈

TA貢獻1836條經(jīng)驗 獲得超5個贊

您不必要求 git 同步完整的存儲庫歷史記錄,它通常是最方便且便宜的,可以在您在那里的時候完成。在比較它們之前嘗試讓 svn 和 git 做同樣的事情。 svn up只關心當前的提示,對其余的根本不做任何檢查。


$ time git ls-remote git://github.com/torvalds/linux refs/heads/master

6e8ba0098e241a5425f7aa6d950a5a00c44c9781        refs/heads/master


real    0m0.536s

user    0m0.004s

sys     0m0.007s

$

毫不奇怪,使用 svn 和 git 檢查單個遠程提示所花費的時間大致相同。


您當前分支的簡稱是git symbolic-ref -q --short HEAD(否則您不在分支上)。


所以你的 svn up 正在做的更接近的等價物是


if branch=`git symbolic-ref -q --short HEAD` && 

    remote=`git config branch.$branch.remote` &&

    merge=`git config branch.$branch.merge` &&

    upstreamtip=`git ls-remote $remote $merge | cut -f1` &&

    test $upstreamtip != `git rev-parse @{u}`

        then git pull $remote $merge

fi


查看完整回答
反對 回復 2022-06-28
  • 1 回答
  • 0 關注
  • 158 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號