如何删掉github上的master分枝.

假设,代码已经被clone到了本地。第一步要做的就是创建一个新的分支,比如placeholder,然后用-D从本地删除master分支。

git branch placeholder
git checkout placeholder
git branch -D master

如果现在删除github上的master,会报错:

git push origin :master

报错结果大概是这样:

remote: error: refusing to delete the current branch: refs/heads/master
To git@github.com:matthew-brett/datarray.git
! [remote rejected] master (deletion of the current branch prohibited)
error: failed to push some refs to 'git@github.com:matthew-brett/datarray.git'

正确地做法是先checkout到新建的placeholder分支。然后把placeholder推送到github上。

git checkout placeholder # if not on placeholder already
git push origin placeholder

从github的web端入到工程的setting界面,有个地方可以更改默认的分支,用另一个分支做默认分支,而不是master。现在就可以从删掉master了

git push origin :master

另,怎么给github上一个tag更名等:

1) 删除本地的一个tag: git tag -d v0.4
2) 删除GitHub上一个tag (这会删除掉下载链接): git push origin :v0.4
3) 给当前branch打标签: git tag -a v0.5 -m "Version 0.5 Stable"
4) 把所有tag推上github(two dashes): git push --tags

copyright ykyi.net

Leave a Reply

Your email address will not be published. Required fields are marked *