git2go
git2go copied to clipboard
How to delete remote branch?
As the title says, anyone knows how to delete a remote branch? I'm trying to base myself on examples from other languages, to no success.
This shows some of the things I've tried, strange or maybe not, these don't return an error, but don't delete the remote branch either:
remote, err := r.Remotes.Lookup("origin")
if err != nil {
log.Fatal(err)
}
//err = remote.Push([]string { ":release/v10.0.5" }, &git.PushOptions{
//err = remote.Push([]string { ":refs/remotes/origin/release/v10.0.6" }, &git.PushOptions{
err = remote.Push([]string { "+:refs/heads/release/v10.0.6" }, &git.PushOptions{
RemoteCallbacks: git.RemoteCallbacks{
CredentialsCallback: repo.NewSshCredentialsCallback(),
CertificateCheckCallback: repo.NewCertificateCheckCallback(),
},
})
if err != nil {
log.Fatal(err)
}
Thanks
I only know how to do this at the protocol level (tell the remote to assign the ref to an all-zeroes hash), but if i'm interpreting https://git-scm.com/book/en/v2/Git-Internals-The-Refspec#_deleting_references correctly, ":refs/heads/release/v10.0.6" (without the leading + since that's only for fetch/pull in the config) may work.