I want to delete a branch locally and remote. My code:
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]);
}
But I get the 401 error ("Unauthorized"). And it's because of the presence of the ":" in the name of the branch.
But I read that they are necessary, because of they are like "--delete" in native git.
Thanks for any helps!
 
     
    