推送到远程私有 Git 仓库提示 checked out
在远程主机上建立了私有 Git 仓库。
在本地执行 git push
向远程私有 Git 仓库推送代码时,Git 提示 ! [remote rejected] master -> master (branch is currently checked out)
,无法推送。
(根据分支名称不同,也可能是 ! [remote rejected] main -> main (branch is currently checked out)
)。
这个问题如何解决?
问了 ChatGPT,它回答:
当你在非裸仓库(即带有工作区的仓库)直接
git push
到当前分支时,可能会导致工作区文件与提交不一致。Git 通过receive.denyCurrentBranch
来防止或处理这种情况。将
receive.denyCurrentBranch
设为updateInstead
,就允许来自外部的git push
,并自动更新工作区。
具体的解决方案如下:
1 |
|
搞定!
图片版权
题图:https://www.deviantart.com/black-pixel/art/Git-Wallpaper-Clean-357130508
求扫码打赏
“我这么可爱,请给我钱 o(*^ω^*)o”


推送到远程私有 Git 仓库提示 checked out
https://blog.kukmoon.com/a3e006830e2b/