Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remote rejected to delete git remote branch

Tags:

git

github

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!

Update:

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.

like image 409
Jared Forth Avatar asked Sep 06 '25 16:09

Jared Forth


1 Answers

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.

like image 56
bk2204 Avatar answered Sep 08 '25 12:09

bk2204