问题描述
我使用这个答案作为指导:https://stackoverflow.com/a/67240436/2112275
use git2::Repository;
fn main() {
let repo = Repository::clone("https://github.com/rossmacarthur/dotfiles","/tmp/dots")
.expect("Failed to clone repo");
let refname = "master"; // or a tag (v0.1.1) or a commit (8e8128)
let (object,reference) = repo.revparse_ext(refname).expect("Object not found");
repo.checkout_tree(&object,None)
.expect("Failed to checkout");
match reference {
// gref is an actual reference like branches or tags
Some(gref) => repo.set_head(gref.name().unwrap()),// this is a commit,not a reference
None => repo.set_head_detached(object.id()),}
.expect("Failed to set HEAD");
}
它似乎有效,但我总是以分离状态结束(尽管引用匹配 Some)。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)