4

I'm using gitolite for git access right management.

I want to rename the master branch to production.

I have RW+ permision on that repo in gitolite

I rename the branch localy with :

git branch -m master production

and then I want to delte the remote master branch, but I get:

remote: error: By default, deleting the current branch is denied, because the next
remote: error: 'git clone' won't 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 gitolite@virgo:/puppeteer
 ! [remote rejected] master (deletion of the current branch prohibited)

How can I remove the master branch also on remote?

simonC
  • 4,101
  • 10
  • 50
  • 78

3 Answers3

1

The Question is why do you delete the master Branch. Its much easier to make a new Branch and push the new branch to your remote server.

git checkout master
git branch production
git checkout production
git push origin production

Then you have a new Remote Branch.

René Höhle
  • 26,716
  • 22
  • 73
  • 82
  • I dont want to have a branch named master in that repo because it wil be used for puppet environments, and the branch name have to represent the environment name. In short i would like to rename the master branch to production and this branch to behave as it would be the master branch. So when ayone clone the repo the main branch for him would be production. – simonC Oct 13 '14 at 09:51
  • You don't need to rename the branch. Make a new branch from master and push them. After that delete the master branch. – René Höhle Oct 13 '14 at 09:52
  • That was exactly what I did ... but I can not delete the master branch on remote becouse of the mentioned error, how can I set receive.denyDeleteCurrent to ignore if I'm using gitolite to manage the remote repository? – simonC Oct 13 '14 at 11:17
  • This is an old question, but I had the exact issue (repo to use with puppet) and the only option I could find was to delete the entire remote repo and re-push it. – yakatz Oct 12 '15 at 19:20
0

I realize this question is now over 6 years old, but the answer is that you don't want to remove the default branch without telling the git server what to use if someone clones that branch in the future.

Instructions for gitolite were referenced in this answer.

Note that you need to enable the symbolic-ref command in order to execute this remotely by adding it to the list of commands in your .gitolite.rc file for the git user on your server.

Once enabled, you should be able to run

ssh <gituser@yourserver> symbolic-ref puppeteer HEAD refs/heads/production

to change the default branch, and then you should be able to delete the old master branch.


Updated per @LaomaiWeng's comment where I was missing an 's'

gaige
  • 17,263
  • 6
  • 57
  • 68
0

I can't comment on gaige's answer so I'm adding this as an answer, but I had to use refs/heads/production (note the s in heads), because that was the path to the ref in my Git repo. There's another answer below the one linked by gaige that has heads too, and the current Git documentation also uses heads.