我想克隆一些远程存储库,但只检索主分支。
我的代码当前获取所有分支。
def init_remote(repo, name, url):
# Create the remote with a mirroring url
remote = repo.remotes.create(name, url, "+refs/*:refs/*")
# And set the configuration option to true for the push command
mirror_var = "remote.{}.mirror".format(name)
repo.config[mirror_var] = True
# Return the remote, which pygit2 will use to perform the clone
return remote
pygit2.clone_repository(url, "../../clones/"+location, remote=init_remote)发布于 2016-04-20 06:34:01
您的代码不只是获取所有分支,它还镜像遥控器,获取其远程跟踪分支,这可能会导致一些令人困惑的布局。
您已经设置了自己的refspec,所以您需要做的是设置refspec以下载默认分支。如果你知道它,你可以修改代码,只得到一个分支
remote = repo.remotes.create(name, url, "+refs/heads/master:refs/heads/master")https://stackoverflow.com/questions/34711540
复制相似问题