Git: Shallow copies from a specific commit

后端 未结 2 755
长情又很酷
长情又很酷 2021-01-23 01:50

git clone --depth N ... creates a shallow clone with history limited to the last N revisions and I can use git clone -b tag ... to fetch the commits re

相关标签:
2条回答
  • 2021-01-23 02:33

    If running at least Git 2.11 on both client and server side, there's a work-around if you know the date of the tagged commit and which branch it is on:

    git clone --branch <branch that contains tag> --shallow-since=<date of tagged commit> <url>
    
    0 讨论(0)
  • 2021-01-23 02:36

    Indeed, there is no direct way, and this kind of counting or multiple-ref-based cloning would have to be implemented on the server side (the server delivering the initial shallow clone) for it to work within git's constraints.

    There's an indirect way though: start with a depth 1 shallow clone, then deepen repeatedly until the tag appears. Annoyingly, git fetch --depth=<N> won't pick up new tags (but you can use git ls-remote or similar to get everything once on the shallow-clone client, and watch for the SHA-1). But I suspect this method would be so slow as to make it pretty worthless.

    0 讨论(0)
提交回复
热议问题