Search code examples
gitgithubspringloops

Git: Cannot Delete Remote Branch ! [remote rejected] (branch is currently checked out)


Cannot delete remote branch because it's checked out?

Ran git push origin --delete development and got this error back ! [remote rejected] development (branch is currently checked out)

I saw a bunch of info on other stack overflows about switching my repository from normal to bare, but I've never had this issue before and the answers seemed overly complicated.

Note I am using springloops (kinda like github) to manage my remote repositories.


Solution

  • First to clarify, the problem isn't that someone on their local machine has that branch checked out.

    This has to deal specifically the remote repository. You're not going to be able to fix this by making a change to you local repository. If you're managing your own remote repositories on your own server you may want to consider looking into the differences between bare and normal repositories. But the big thing that nobody is going to clearly spell out for you is that a bare repository is a repo that does not have a default branch. Which therein lies the answer to our issue.

    If you are using github or springloops and coming up against this issue it is just a matter of changing the default branch, then you will be able to delete the corresponding branch.