我正在尝试删除本地和远程GitLab存储库中的分支。它的名字是origin/feat
。我试过了git push --delete origin feat
。Git抱怨:
remote: error: By default, deleting the current branch is denied, because the next
remote: 'git clone' won't result in any file checked out, causing confusion.
remote:
remote: You can set 'receive.denyDeleteCurrent' configuration variable to
remote: 'warn' or 'ignore' in the remote repository to allow deleting the
remote: current branch, with or without a warning message.
remote:
remote: To squelch this message, you can set it to 'refuse'.
remote: error: refusing to delete the current branch: refs/heads/feat
OK很有意义,所以我尝试切换到origin/master
with git checkout master
,它告诉我:Already on 'master'
。是否还需要在远程目录中设置当前分支?我该怎么做?
编辑(按OP的注释-我没有使用过GitLab):GitLab具有一个带有下拉菜单的Web界面。您需要在“设置”视图(而不是“项目”视图)下的一个。在“默认”分支下的“设置”视图中选择一个分支,然后单击“保存更改”以在服务器上设置当前分支。
您有正确的想法,但必须记住,涉及到两个存储库(两个Git)。
每当您获得带有前缀的文本时remote:
,这意味着该文本来自另一个Git。因此,当您拥有自己的Git时,请另一个Git删除feat
,这是另一个Git抱怨的feat
是当前分支。
因此:
是否还需要在远程目录中设置当前分支?
是的(嗯,“代替”而不是“也”)。
我该怎么办?
通常,对任何存储库都使用相同的方法:登录cd
到存储库目录,然后运行git checkout
。但是在服务器上有一两个带有可推送存储库的地方:
它可能是一个--bare
存储库,因此您不能git checkout
直接使用它。这里的窍门是git symbolic-ref
用来更新HEAD
:
git symbolic-ref HEAD refs/heads/master
当然,这假设您可以登录(请参阅第一点)。举例来说,如果有一个Web界面可以让您更改遥控器上的当前分支,那么它将必须git symbolic-ref
为您执行此操作。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句