The problem of deleting the remote branch

➜  screenwords git:(master) git push origin :master

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 root@182.92.243.187:/home/gitrepos/Website.git

 ! [remote rejected] master (deletion of the current branch prohibited)

error: failed to push some refs to 'root@182.92.243.187:/home/gitrepos/Website.git'


---------------------------------------------------------------------------------------------------

First decide which branch should be the default branch when the repository is cloned. I assume new_master for this example.

On one of the clients create the new_master branch on the remote repository, you may use anything for master instead, e.g. a commit or another branch name, or skip this step if you already have a suitable branch on the remote.

git push origin master:new_master

The next step can't be done from remote, so execute the command in your remote repository (e.g. using SSH):

给远程分支指定HEAD的操作只能在远程通过SSH完成。。

cd /path/to/my_git_repo
git symbolic-ref HEAD refs/heads/new_master

Alternatively, change the content of the HEAD file directly.

Back on the client:

git fetch
git remote show origin

You should see that the HEAD points to new_master instead of master (or that HEAD is ambiguous if you set new_master to be master). Now we can remove the old master:

git push origin :master

Git shouldn't complain anymore about the deletion. Finally, set the local refs/remotes/origin/HEAD:

git remote set-head origin -a 这步是根据remote origin的head来设置本地的引用

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值