使用存储库Network对象进行调试时,实例的快速监视告诉我所有线程都需要运行,这会导致标题中的消息。不知道为什么会出现这种情况,但在推送时我得到了这个消息。
这里真正的问题是为什么下面的推送与移除和重新添加遥控器无关。
代码如下 - 所有参数值均有效。致当地回购的工作正在进行中。只有签名才能在删除并重新添加遥控器后使用遥控器。在这种情况下,分支是正确的。:
private Repository GetGitRepo()
{
string path = Settings.GetSetting(Constants.GitRepositoryPath);
Repository repo = new Repository(path);
return repo;
}
using (var repo = GetGitRepo())
{
if(commit != null)
{
var options = new PushOptions();
options.CredentialsProvider = new CredentialsHandler(
(_url, _user, _cred) =>
new UsernamePasswordCredentials() { Username = Settings.GetSetting(Constants.GitUsername), Password = Settings.GetSetting(Constants.GitPassword) });
repo.Network.Push(_workingBranch, options);
}
}

其他人遇到过这个问题,或者知道我可能缺少什么?
提前致谢!
答案 0 :(得分:0)
所以这是最终奏效的。我认为问题中所述的消息掩盖了另一个问题。最终删除并重新添加遥控器最终成功了。代码发布如下:
using (var repo = GetGitRepo())
{
// clean remote by remove and re-add
var remoteName = Settings.GetSetting(Constants.GitUsername);
repo.Network.Remotes.Remove(remoteName);
Remote remote = repo.Network.Remotes.Add(remoteName, Settings.GetSetting(Constants.GitServer));
// build credentials to repo in PushOptions
var options = new PushOptions();
options.CredentialsProvider = new CredentialsHandler(
(_url, _user, _cred) =>
new UsernamePasswordCredentials() { Username = Settings.GetSetting(Constants.GitUsername), Password = Settings.GetSetting(Constants.GitPassword) });
var pushRefSpec = _workingBranch.CanonicalName;
repo.Network.Push(remote, pushRefSpec, options);
}