Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Github 我怎么能只有一个分支机构?_Github_Github Pages - Fatal编程技术网

Github 我怎么能只有一个分支机构?

Github 我怎么能只有一个分支机构?,github,github-pages,Github,Github Pages,我正在用javascript页面做一些基本的演示——使用github不仅作为源代码控制,还作为托管提供商 我只想在gh pages分支上工作,或者让它自动反映我在master上所做的更改,只要更简单、更干净 我试图删除主分支,但它不允许我: $ git push origin --delete master remote: error: refusing to delete the current branch: refs/heads/master To git@github.com:opens

我正在用javascript页面做一些基本的演示——使用github不仅作为源代码控制,还作为托管提供商

我只想在gh pages分支上工作,或者让它自动反映我在master上所做的更改,只要更简单、更干净

我试图删除主分支,但它不允许我:

$ git push origin --delete master
remote: error: refusing to delete the current branch: refs/heads/master
To git@github.com:opensas/geo-demo.git
! [remote rejected] master (deletion of the current branch prohibited)
我只希望有一个分支(母版或gh页面)以及我提交并推送到它的任何内容,以显示在github页面中


实现这一点的最佳方法是什么?

如果要从GitHub中删除master,必须转到GitHub并将gh pages设置为默认分支。只有这样,您才能删除母版。

尝试在回购协议的设置页面中将“默认分支”设置为“gh页面”,然后删除
母版
分支:

$ git push origin :master

它应该有效

删除主分支时要小心。确保使用回购协议的每个人都知道发生了什么,确保主分支上没有未合并的PRs,并且所有对主分支的提交都已合并到gh页面。总的来说,我认为在更改默认值后,最好让主分支保持一到两周不变。我凭经验说话@SamDutton是的,很好的建议,完全有道理。但这正是op在这种情况下想要做的@kJuy yep-我之所以发出警告是因为我被烧死了:)@SamDutton hahahaha lol b.t.w.,GitHub/BitBucket都提供了分支保护功能,这是避免删除重要分支的好方法。它值得使用;)