我想删除本地和远程的分支。
我的代码:
using (var repository = new Repository(path))
{
var remote = repository.Network.Remotes["origin"];
var options = new PushOptions();
var credentials = options.CredentialsProvider = GetUserCredentialsProvider();
options.CredentialsProvider = credentials;
string pushRefSpec = @"refs/heads/:{0}".FormatWith(branch);
repository.Network.Push(remote, pushRefSpec);
repository.Branches.Remove(repository.Branches[branch]);
}
但我收到 401 错误(“未经授权”)。
这是因为分支名称中存在“:”。
但我读到它们是必要的,因为它们就像本机 git 中的“--delete”。
感谢您的帮助!
由于未经授权,此操作失败并出现 401 未经授权错误。要修复此错误,您只需传递options
包含您的凭据Push()
method:
repository.Network.Push(remote, pushRefSpec, options)
这为我解决了这个问题。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)