英文:
Is it possible to do `git clone --depth=1 <repository>` with libgit2?
问题
我想要快速克隆,而不获取所有 .git
历史记录。是否可以使用 libgit2 来实现这一点?
我找到了 这个问题,但我不确定他们提到的稀疏检出是否与运行 git clone --depth=1 https://github.com/libgit2/libgit2
相同。
英文:
I want to do a quick clone without getting all the .git
history. Is this possible to do with libgit2?
I found this issue but I am not sure if this sparse checkout they reference is
same as running git clone --depth=1 https://github.com/libgit2/libgit2
.
答案1
得分: 2
这是现在可以实现的!libgit2的git_clone函数以git_clone_options作为参数。该结构的一个成员是git_fetch_options,它带有一个深度参数。
请注意,要模仿git clone --depth=1 https://github.com/libgit2/libgit2
,您还需要仅获取单个分支的历史记录。这可以通过通过remote_cb传递您自己的回调函数来实现。
英文:
This is now possible! The libgit2 git_clone function takes git_clone_options as an argument. One of the members of that struct is git_fetch_options which takes a depth parameter.
Note that to mimic git clone --depth=1 https://github.com/libgit2/libgit2
you will also need to fetch only the history for a single branch. This is achieved by passing your own callback via remote_cb.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论