使用 libgit2sharp 拉取特定提交



希望有人打电话帮助。首先,我对 git 很陌生,所以如果我在解释我的问题时犯了一些错误,请原谅我。

我想使用 libgit2sharp 的库将存在的源代码拉到特定的提交。所以如果有历史

我希望能够提取 5 或该列表中的任何其他数字的源代码。不会标记任何源,因此我必须使用提交进行拉取。希望有人能帮忙。

我已经看过 https://github.com/libgit2/libgit2sharp/wiki/git-pull 但它似乎不允许我通过 sha 或提交 id。

编辑了我的问题,以明确我正在使用库。

所以另一个开发人员回答了这个问题。我需要做的就是克隆,然后针对我要重置的提交进行检查。这似乎按照我想要的方式工作。

//clone the master 
dir = Path.Combine(localPath, "Target");
Directory.CreateDirectory(dir);
Repository.Clone(tfsUri, dir);
//reset master to the base of the branch
using (var localRepo = new Repository(dir))
{
var localCommit = localRepo.Lookup<Commit>(priorCommitId);
Commands.Checkout(localRepo, localCommit);
}

不确定这是否是你的意思@0andriy,但你的评论有点令人困惑。

最新更新