gpt4 book ai didi

c - 用 libgit2 实现 'git pull'?

转载 作者:太空狗 更新时间:2023-10-29 13:03:02 25 4
gpt4 key购买 nike

我有a relatively short Gist它应该使用 libgit2 来模拟 git pull 命令的功能。不幸的是,它不是很有效。

总而言之,该片段:

根据 git_remote_stats() ,确实正在获取对象。但是工作目录不会更改以反射(reflect)最新的提交。我尝试添加:

git_checkout_head(repo, NULL);

...但这没有什么区别。

输入:

git checkout master

...在终端中产生以下输出:

Already on 'master'Your branch is behind 'origin/master' by 1 commit, and can be fast-forwarded.

如何快进?

最佳答案

你应该运行 git pull origin master

git fetch origin + git merge origin/master

复制代码

那么意味着您需要等效的 libgit2 merge 功能。

merge 功能在 libgit2 v0.20 中可用

关于c - 用 libgit2 实现 'git pull'?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15492375/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com