English 中文(简体)
• 如何改称主编,以掌握一个Github存放处
原标题:How to rename main branch to master on a Github repository
  • 时间:2020-10-24 15:09:48
  •  标签:
  • git
  • github

我愿设立一个有色人种的存放处,并改名为<代码>main Branch to master/code>。

If I create a new repository on github and do

git init
git add README.md
git commit -m "first commit"
git branch -M master

error: refname refs/heads/master not found
fatal: Branch rename failed

因此,我似乎不太明白。 这个问题是什么?


在我与上述两点玩.的时候,我不得不感到困惑。 情况如下:

git init create the repository

<代码>git 添加README.md 增加档案

。 自此以后,该行业一直没有资格

so I never have to rename it in the first place. Now Github uses the default main, which can be changed in settings -> repositories on github.com

最佳回答

README.md 事实上,<代码>giteckout-B Master将做你想要的事情。 <代码>git Branch -M, 预计将产生一种完全的参考,即实际指的是什么,而不是git init>(或giteckout --orphan)。 我同意,“应当”处理本案,无论它是否值得一派,是否由能够撰写好件的人负责。 页: 1

我的测试案例导致这一答案,只是把你的指挥用在一张空洞的目录上;这产生了你报告的症状。 将其放在名录上,该名录(已读)包括一个<编码> README.md。 工作方式是你想要的,即不产生这一错误。 您或许会期望git init 创设一个默认README.md?

问题回答

采用<代码>-m 备选办法(去除/改名)而不是-M,改用本部的名称。 然后,你可以把你更名为分支机构,并保持你的log。

git branch -m main master
git push -u origin master

我也写了博客员额,其中有许多细节,在重新命名分行之前,如果该回波被他人带上手铐的话。 您可以在此检查。

我这样做了。 吉特·霍恩也应如此。

在项目根基上,在您的终点站开设这些线路。

git branch -m main master
git push -u origin master
git push origin --delete main

然后,我将<代码>master/code>作为违约事务组。





相关问题
git confusion - cloning a repo is returning a past version

Im having some confusion with my git usage. I cloned a repo from one comp to the other, and the new clone is the state of the original that was active some time ago. So its cloning a past version. ...

Appropriate strategy for tagging and hotfixing with git

I was wondering if the strategy I m using for tagging and hotfixing tags (which then I use for deploying rails applications) with git is appropriate. For tagging I just tag a commit of the master ...

Tips on upgrading CVS to git/hg?

We still use CVS, I use git and hg for my personal use though I m still a novice at both, but I realize they re much more modern and better, faster, distributed, etc. It s just everyone is so ...

Using Git in a TFS shop

Using Git at home has spoiled me - I now find using TFS at work to be a bit of a drag and want to explore the possibility of using Git locally and syncing somehow with TFS. I figure there are a few ...

热门标签