How to git fetch efficiently from a shallow clone

前端 未结 5 643
长情又很酷
长情又很酷 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

    Just did g clone github.com:torvalds/linux and it took so much time, so I just skipped it by CTRL+C.

    Then did g clone github.com:torvalds/linux --depth 1 and it did cloned quite fast. And I have only one commit in git log.

    So clone --depth 1 should work. If you need to update existing repository, you should use git fetch origin remoteBranch:localBranch --depth 1. It works too, it fetches only one commit.

    Summing up:

    Initial clone:

    git clone git_url --depth 1
    

    Code update

    git fetch origin remoteBranch:localBranch --depth 1
    

提交回复
热议问题