How to git fetch efficiently from a shallow clone

前端 未结 5 633
长情又很酷
长情又很酷 2020-11-27 03:53

We use git to distribute an operating system and keep it upto date. We can\'t distribute the full repository since it\'s too large (>2GB), so we have been using shallow clon

5条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-27 04:45

    Note that Git 1.9/2.0 (Q1 2014) could be more efficient in fetching for a shallow clone.
    See commit 82fba2b, from Nguyễn Thái Ngọc Duy (pclouds):

    Now that git supports data transfer from or to a shallow clone, these limitations are not true anymore.

    All the details are in "shallow.c: the 8 steps to select new commits for .git/shallow".

    You can see the consequence in commits like 0d7d285, f2c681c, and c29a7b8 which support clone, send-pack /receive-pack with/from shallow clones.
    smart-http now supports shallow fetch/clone too.
    You can even clone form a shallow repo.

    Update 2015: git 2.5+ (Q2 2015) will even allow for a single commit fetch! See "Pull a specific commit from a remote git repository".

    Update 2016 (Oct.): git 2.11+ (Q4 2016) allows for fetching:

    • since a date --shallow-since=
    • up to a commit --shallow-exclude=
    • with a greater depth: --deepen=N

提交回复
热议问题