我有一个本地存储库,我想镜像到远程'websrv'.这曾经工作正常,直到我删除了一个本地分支.现在当我这样做
git push --mirror websrv
Run Code Online (Sandbox Code Playgroud)
我明白了
remote: error: By default, deleting the current branch is denied, because the next
remote: error: 'git clone' won't result in any file checked out, causing confusion.
remote: error:
remote: error: You can set 'receive.denyDeleteCurrent' configuration variable to
remote: error: 'warn' or 'ignore' in the remote repository to allow deleting the
remote: error: current branch, with or without a warning message.
remote: error:
remote: error: To squelch this message, you can set it to 'refuse'.
remote: error: refusing to delete the current branch: refs/heads/ecoli-moments
To git@141.89.117.199:~/baki_tracking.git
! [remote rejected] ecoli-moments (deletion of the current branch prohibited)
Run Code Online (Sandbox Code Playgroud)
分支'ecoli-moments'指向与master,local和remote相同的提交.
我该怎么办才能正确删除远程分支?
更新:
远程存储库是裸的,我检查了服务器上的目录(配置文件有bare = true).
Jan*_*dec 16
即使是裸存储库也有一个当前分支.克隆存储库时,默认情况下将检出该选项.Git不想删除它,并告诉你原因.
默认分支是特殊HEAD引用.将其修改为指向预期始终存在的内容,或指向修订.另请参见origin/HEAD如何设置?.
您必须在服务器上使用git symbolic-ref(1)手动更改HEAD指向的内容.
或者您可以将错误中提到的选项设置为false(git config receive.denyDeleteCurrent false在服务器上); 如果它只是一个备份(--mirror主要仅适用于备份),默认分支并不重要.