我正在使用LibGit2Sharp并在克隆存储库并尝试调用PULL命令后,总是会出现相同的错误。 我试图使用结账,重置,合并而不是更改。
public void RecuperarRepositorio()
{
if (!Directory.Exists(DS_CAMINHO_DESTINO + @"\.git"))
CriarRepositorio();
else
AtualizarRepositorio();
}
private void CriarRepositorio()
{
var path = Repository.Clone(DS_CAMINHO_GIT, DS_CAMINHO_DESTINO, RetornaCloneOptions());
}
private void AtualizarRepositorio()
{
using (var repo = new Repository(DS_CAMINHO_DESTINO + @"\.git\"))
{
foreach (Remote remote in repo.Network.Remotes)
repo.Network.Fetch(remote, RetornaPullOptions().FetchOptions);
repo.Network.Pull(RetornaAssinatura(), RetornaPullOptions());
}
}
private CloneOptions RetornaCloneOptions()
{
var co = new CloneOptions();
co.BranchName = NM_BRANCH;
co.CredentialsProvider = (_url, _user, _cred) => RetornaCredencial();
co.CertificateCheck += delegate(Certificate certificate, bool valid, string host) { return true; };
return co;
}
private PullOptions RetornaPullOptions()
{
var po = new PullOptions();
po.FetchOptions = new FetchOptions();
po.FetchOptions.TagFetchMode = TagFetchMode.All;
po.FetchOptions.CredentialsProvider = (_url, _user, _cred) => RetornaCredencial();
po.FetchOptions.CertificateCheck += delegate(Certificate certificate, bool valid, string host) { return true; };
po.MergeOptions = new MergeOptions();
po.MergeOptions.FileConflictStrategy = CheckoutFileConflictStrategy.Theirs;
return po;
}