How to delete master branch from git server

Today I needed to remove the master branch from a remote repository, but when I did it I got this message:

git push origin :master
remote: error: By default, deleting the current branch is denied, because the next
remote: error: git clone wont result in any file checked out,
causing confusion.
remote: error:
remote: error: You can set receive.denyDeleteCurrent configuration variable to
remote: error: warn or ignore in the remote repository to allow deleting the
remote: error: current branch, with or without a warning message.
remote: error:
remote: error: To squelch this message, you can set it to refuse.
remote: error: refusing to delete the current branch: refs/heads/master
To ssh://server_name/git/repository.git
! [remote rejected] master (deletion of the current branch prohibited)
error: failed to push some refs to ssh://server_name/git/repository.git

By default the git server does not allow to delete the current branch (usually is the master branch) , but you can change this behavior by doing the following steps:

ssh git_server_ip -l root
sudo -u git_user git config --system receive.denyDeleteCurrent warn
sudo -u git_user git config --global receive.denyDeleteCurrent warn

See more details about Git config.

comments powered by Disqus