我在服务器上有一个裸露的 git 存储库,其默认分支名为master. 我想把名字改成main.
当我搜索说明时,总是被告知在删除分支之前将defaultGitHub 上的分支更改为新分支。但我的仓库不在 GitHub 上。
当我尝试删除时,我收到此错误消息:mainmastermaster
$ git push origin --delete master
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/master
To server:projects/repo.git
! [remote rejected] master (deletion of the current branch prohibited)
error: failed to push some refs to 'server:projects/repo.git'
Run Code Online (Sandbox Code Playgroud)
到目前为止我做了什么:
$ git branch -m master main
$ git push -u origin main
Run Code Online (Sandbox Code Playgroud)
如何删除master分支并将分支设置main为新的默认分支,以便将来git clone不会导致签出空目录?
我在这里找到了适合我的解决方案:
Git:正确的方法来更改裸存储库中的活动分支?
由于我可以访问服务器上的裸存储库,因此我执行了以下操作:
[server:~/projects/repo.git]$ git symbolic-ref HEAD refs/heads/main
Run Code Online (Sandbox Code Playgroud)
然后在我的本地副本上我可以git push origin --delete master没有错误。
该存储库的新版本默认git clone检查了所有文件和分支。main
| 归档时间: |
|
| 查看次数: |
1357 次 |
| 最近记录: |