git push 失败

在本地仓库使用 git push 命令时出现一下错误

remote: error: refusing to update checked out branch: refs/heads/master
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 to
remote: error: 'ignore' or 'warn' in the remote repository to allow pushing into
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 some
remote: error: other way.
remote: error: 
remote: error: To squelch this message and still keep the default behaviour, set
remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.

这是因为,git默认是禁止 push 操作

需要进行如下修改,在远程仓库目下下,修改 .git/config 文件

在文件最后添加


    [receive]
    denyCurrentBranch = ignore


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
git push失败可能有以下六种常见原因: 1. 权限不足:你没有权限将代码推送到该项目。这可能是因为你没有被授予推送代码的权限,或者你正在尝试将代码推送到一个只读的仓库。解决方法是联系项目管理员或仓库所有者,请求相应的权限。 2. 分支保护:该项目可能启用了分支保护功能,只允许特定的分支接受推送。如果你正在尝试将代码推送到受保护的分支,但没有相应的权限,就会出现推送失败的错误。解决方法是检查你正在推送的分支是否受到保护,并确保你有相应的权限。 3. 代码冲突:如果你的本地代码与远程仓库中的代码发生冲突,git push操作将会失败。这通常发生在多人协作开发时,多个人同时修改了同一部分代码。解决方法是先解决代码冲突,然后再进行推送。 4. 仓库不存在:你可能正在尝试将代码推送到一个不存在的仓库。请确保你输入的仓库地址或名称是正确的,并且该仓库确实存在。 5. 网络连接问题:推送失败也可能是由于网络连接问题导致的。请检查你的网络连接是否正常,并尝试重新推送。 6. 用户身份验证问题:如果你的身份验证信息不正确或过期,git push操作将会失败。解决方法是使用正确的用户名和密码或访问令牌进行身份验证。 请根据具体情况检查以上六种原因,并采取相应的解决方法来解决git push失败的问题。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值