Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/20.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

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中重命名分支_Git_Github - Fatal编程技术网

在github中重命名分支

在github中重命名分支,git,github,Git,Github,我想将分支从“master”重命名为“introduction”。我找到了不同的链接,但把我弄糊涂了。有什么帮助吗 我试过了,但没用 git branch -m old_branch new_branch # Rename branch locally git push origin :old_branch # Delete the old branch git push --set-upstream origin new_bran

我想将分支从“master”重命名为“introduction”。我找到了不同的链接,但把我弄糊涂了。有什么帮助吗

我试过了,但没用

git branch -m old_branch new_branch         # Rename branch locally    
git push origin :old_branch                 # Delete the old branch    
git push --set-upstream origin new_branch   # Push the new branch, set local   
branch to track the new remote

转到
https://github.com///settings/branches
并将默认分支更改为不希望删除的分支,然后重试。无法删除GitHub中的默认分支。

1/正确的顺序是:

git branch -m old_branch new_branch         # Rename branch locally    
git push --set-upstream origin new_branch   # Push the new branch, set local   
branch to track the new remote

# go to GitHub and select new_branch as your default one

git push origin :old_branch                 # Delete the old branch    
2/:

指向已删除分支的链接现在重定向到默认分支 以前,当GitHub上的分支被删除时,任何包含旧分支名称的链接都会在StackOverflow、email、Slack和其他集成中中断

指向已删除分支的链接现在重定向到默认分支。

因此,例如,链接现在将重定向到默认分支上的等效链接:

此更改仅影响视图链接;其他类型的链接(如编辑链接和责备链接)不会重定向

此更改是GitHub为支持希望重命名其默认分支的项目和维护人员所做的许多更改中的第一个更改。
要了解有关我们正在进行的更改的更多信息,请参阅

3/从2021年1月开始

这是直接支持的

见“


可能与@Dario重复,这有什么帮助?他完全按照公认的答案做了,但没有成功。@Theo“不起作用”是什么意思?你收到错误消息了吗?@吸血鬼。我到了我的github,看到了主分支。它没有被重命名。但是您在发出这些命令时是否有任何错误?也许您必须更改GitHub上的默认分支才能使其正常工作。我现在可以看到介绍分支了!谢谢你。不过,我认为应该有办法删除主分支。我的意思是从终端(在我的例子中是gitbash)开始,只要它被配置为GitHub中的默认分支就行。GitHub不允许删除正在使用的默认设置。;-)当然,GitLab并不落后: