LibGit2Sharp - The current branch is configured to merge with the reference '' from the remote, but this reference was not fetched

筅森魡賤 提交于 2019-12-24 15:39:03

问题


I'm using LibGit2Sharp and after cloning the repository and try to call the PULL command, always gives the same error. I've tried to use checkout, reset, merging and not changed.

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;
}

来源:https://stackoverflow.com/questions/37215864/libgit2sharp-the-current-branch-is-configured-to-merge-with-the-reference-f

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!