git错误“无法推送一些引用到xxx"的解决方法

服务器上挂了2块硬盘,于是用git作为备份工具,把硬盘1上的数据备份到硬盘2(即把硬盘2当远程仓库),当push的时候,git报错了

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'.
To /data/bbs
 ! [remote rejected] master -> master (branch is currently checked out)
error: 无法推送一些引用到 '/data/bbs'

 提示'receive.denyCurrentBranch' configuration variable to 'refuse'. To /data/bbs  ,所以需要在远程仓库中修改git的config

打开 .git/config

在后面增加

[receive]
denyCurrentBranch = ignore

 然后再push就不会被拒绝了

转载于:https://www.cnblogs.com/fixbug/p/6962701.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
回答: 要拉取最新的代码,可以使用git pull命令。在你拉取的代码文件夹内点击git bash here,然后输入git pull,就可以拉取更新后的代码。这样就不需要再从远程仓库克隆代码了,可以直接在文件夹下进行操作。\[1\]而要推送代码到远程仓库,可以使用git push命令。先使用git add将工作区的代码改动添加到暂存区,然后使用git commit -m "xxx"将暂存区的代码提交到本地分支,最后使用git push将本地分支的代码推送到远程分支上。\[2\]在克隆远程项目时,本地分支会自动与远程仓库建立追踪关系,可以使用默认的origin来替代远程仓库名,所以常用的命令是git pull origin <远程仓库名>,操作简单、安全可控。\[3\] #### 引用[.reference_title] - *1* [Git如何拉取代码以及将本地代码推送到远程仓库](https://blog.csdn.net/weixin_48991062/article/details/108386419)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [git入门:git常用命令 | 代码的拉取、修改、提交、推送命令及原理](https://blog.csdn.net/m0_56257585/article/details/125324361)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] - *3* [git操作之pull拉取远程指定分支以及push推送到远程指定分支](https://blog.csdn.net/qq_45467083/article/details/108529813)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值