I am having an issue with a git remote branch that refuses to be deleted.
As per this answer, I have deleted my local branch with git branch -d qa
without any issues, but when I run git push --delete origin qa
to delete the remote branch I get the error:
! [remote rejected] qa (refusing to delete the current branch: refs/heads/qa)
I get the same error when running git push origin :qa
, and when I try to force the deletion with git push --force origin :qa
or the variation of git push origin --delete --force qa
.
Does anyone know to to force the deletion of the remote branch?
If it is relevant, I am running git version 2.17.1
Thanks!
The issue was that qa
was set as the default branch. In my repository I went to Settings > Branches > Default Branch
and changed it to master, which allowed me to run git push --delete origin qa
with no errors.
GitHub doesn't let you delete the default branch using Git.
You can either change the default branch to something else and then delete the qa
branch, or you can delete the branch using the API.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With