{"id":392,"date":"2012-08-01T08:30:31","date_gmt":"2012-08-01T13:30:31","guid":{"rendered":"http:\/\/ebixio.com\/blog\/?p=392"},"modified":"2012-07-09T22:11:45","modified_gmt":"2012-07-10T03:11:45","slug":"git-deleting-the-current-branch-is-denied","status":"publish","type":"post","link":"http:\/\/ebixio.com\/blog\/2012\/08\/01\/git-deleting-the-current-branch-is-denied\/","title":{"rendered":"Git &#8211; deleting the current branch is denied"},"content":{"rendered":"<p>Here&#8217;s a solution if you ever get the following error when trying to delete the master branch in a remote repository:<\/p>\n\r\n<pre class=\"brush: plain; highlight: [9]; title: ; notranslate\" title=\"\">\r\nremote: error: By default, deleting the current branch is denied, because the next\r\nremote: error: 'git clone' won't result in any file checked out, causing confusion.\r\nremote: error: \r\nremote: error: You can set 'receive.denyDeleteCurrent' configuration variable to\r\nremote: error: 'warn' or 'ignore' in the remote repository to allow deleting the\r\nremote: error: current branch, with or without a warning message.\r\nremote: error: \r\nremote: error: To squelch this message, you can set it to 'refuse'.\r\nremote: error: refusing to delete the current branch: refs\/heads\/master\r\nTo \/somewhere\/in\/the\/cloud\/repo.git\r\n ! &#x5B;remote rejected] master (deletion of the current branch prohibited)\r\nerror: failed to push some refs to '\/somewhere\/in\/the\/cloud\/repo.git'\r\n<\/pre>\r\n<p>The reason you&#8217;re seeing the error is that HEAD on the remote repository by default contains something like this (see also line 9 in the error message above):<\/p>\n\r\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nref: refs\/heads\/master\r\n<\/pre>\r\n<p>If you have access to the remote repository, simply modify the <strong>HEAD<\/strong> file to point to a different branch and then you&#8217;ll be able to delete the remote master branch. There are some significant implications to modifying the remote <strong>HEAD<\/strong>, especially if other users are tracking that branch, so make sure you know what you&#8217;re doing if you choose to point it to some other arbitrary branch.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here&#8217;s a solution if you ever get the following error when trying to delete the master branch in a remote repository: remote: error: By default, deleting the current branch is denied, because the next remote: error: &#8216;git clone&#8217; won&#8217;t result in any file checked out, causing confusion. remote: error: remote: error: You can set &#8216;receive.denyDeleteCurrent&#8217; [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[1],"tags":[4],"class_list":["post-392","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-git"],"_links":{"self":[{"href":"http:\/\/ebixio.com\/blog\/wp-json\/wp\/v2\/posts\/392","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/ebixio.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/ebixio.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/ebixio.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/ebixio.com\/blog\/wp-json\/wp\/v2\/comments?post=392"}],"version-history":[{"count":10,"href":"http:\/\/ebixio.com\/blog\/wp-json\/wp\/v2\/posts\/392\/revisions"}],"predecessor-version":[{"id":401,"href":"http:\/\/ebixio.com\/blog\/wp-json\/wp\/v2\/posts\/392\/revisions\/401"}],"wp:attachment":[{"href":"http:\/\/ebixio.com\/blog\/wp-json\/wp\/v2\/media?parent=392"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/ebixio.com\/blog\/wp-json\/wp\/v2\/categories?post=392"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/ebixio.com\/blog\/wp-json\/wp\/v2\/tags?post=392"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}