Git学习之常见错误 git push 失败

mac2022-06-30  22

Git学习之常见错误 git push 失败


 

问题描述:

git push Counting objects: 6, done. Delta compression using up to 8 threads. Compressing objects: 100% (4/4), done. Writing objects: 100% (6/6), 445 bytes | 445.00 KiB/s, done. Total 6 (delta 3), reused 0 (delta 0) remote: error: refusing to update checked out branch: refs/heads/5.1 remote: error: By default, updating the current branch in a non-bare repository remote: error: is denied, because it will make the index and work tree inconsistent remote: error: with what you pushed, and will require 'git reset --hard' to match remote: error: the work tree to HEAD. remote: error: remote: error: You can set 'receive.denyCurrentBranch' configuration variable t remote: error: 'ignore' or 'warn' in the remote repository to allow pushing int remote: error: its current branch; however, this is not recommended unless you remote: error: arranged to update its work tree to match what you pushed in som remote: error: other way. remote: error: remote: error: To squelch this message and still keep the default behaviour, se remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'. To ...

解决办法:

这是由于git默认拒绝了push操作,根据提示信息解决:

You can set 'receive.denyCurrentBranch' configuration variable to 'ignore' or 'warn' in the remote repository to allow pushing into...

进入项目的目录下的.git目录,编辑config文件:

增加一项配置:

[receive] denyCurrentBranch = ignore

然后再次执行 git push,就可以成功了。

这是服务器上看不到刚提交的文件,需要执行:

git reset --hard

然后就OK了。

在初始化远程仓库时最好使用 git init --bare

而不要使用:git init


 

转载于:https://www.cnblogs.com/gyfluck/p/9599182.html

相关资源:JAVA上百实例源码以及开源项目
最新回复(0)