我无法删除 git 上的远程主分支 [英] I can't delete a remote master branch on git

查看:45
本文介绍了我无法删除 git 上的远程主分支的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要删除一个主分支,但事实证明这很困难.我只想清理那个分支并开始新的.我正在从 dev 分支中删除.我希望 GitHub 上的 master 是干净的.

 # git push origin --delete master>到 https://github.com/mymasterb.git !【远程拒绝】大师>(禁止删除当前分支)error: failed to push some>参考https://github.com/mymaster.git"

我如何简单地用新石板开始我的主人?

解决方案

这是于 2013 年 9 月宣布,一个在我最初写下这个答案一年后.

<块引用>

对于文档修复、拼写错误等小改动,或者如果您只是一个行走的软件编译器,您可以在浏览器中完成很多工作,而无需将整个存储库克隆到您的计算机上.

<小时>

注意:对于 BitBucket,Tum 报告 在评论中:

<块引用>

Bitbucket 大致相同

Repo ->设置 ->存储库详细信息 ->主枝

I need to delete a master branch, but it's proving to be hard. I just want to clean that branch out and start new. I am deleting from the dev branch. I want master on GitHub to be clean.

 # git push origin --delete master

> To https://github.com/mymasterb.git  ! [remote rejected] master
> (deletion of the current branch prohibited) error: failed to push some
> refs to 'https://github.com/mymaster.git'

How do I quite simply start my master with a fresh slate?

解决方案

As explained in "Deleting your master branch" by Matthew Brett, you need to change your GitHub repo default branch.

You need to go to the GitHub page for your forked repository, and click on the "Settings" button.

Click on the "Branches" tab on the left hand side. There’s a "Default branch" dropdown list near the top of the screen.

From there, select placeholder (where placeholder is the dummy name for your new default branch).

Confirm that you want to change your default branch.

Now you can do (from the command line):

git push origin :master

Or, since 2012, you can delete that same branch directly on GitHub:

That was announced in Sept. 2013, a year after I initially wrote that answer.

For small changes like documentation fixes, typos, or if you’re just a walking software compiler, you can get a lot done in your browser without needing to clone the entire repository to your computer.


Note: for BitBucket, Tum reports in the comments:

About the same for Bitbucket

Repo -> Settings -> Repository details -> Main branch

这篇关于我无法删除 git 上的远程主分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆