Git学习之常见错误 git push 失败
2023-09-11 14:22:41 时间
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
相关文章
- Centos6.8搭建Git服务(git版本可选)
- GHOST还原时错误An internal inconsistency has been detected..Internal Error 25002解决办法(-ntexact参数)
- exportfs 入门/ 错误
- Foundation HTML5 Canvas中的2处错误
- git 错误: Unable to find remote helper for 'https'
- 删除sql server用户时报15138错误
- [Git] Recover Local Changes from `git reset --hard` with `git reflog`
- [Practical Git] Filter commit history with git log arguments
- 错误 内存溢出 vendor/composer/autoload_real.php on line 66
- 关于WIN8使用 VMware player 6 出现“开机时出错:内部错误”的解决
- [Practical Git] Remove unnecessary git tracking with .gitignore files
- [Practical Git] Compare file changes with git diff
- [Practical Git] Format commit history with git log arguments
- git 邮箱错误-git log 中发现 XXX@163.com邮箱不符合要求,请务必使用公司邮箱。
- 部署 SAP UI5 应用到 SAP BTP 时遇到的 error retrieving MTA 错误消息
- 从 SAP WebIDE 里向Github 发起 push 的错误消息 - Git result: REJECTED_NONFASTFORWARD
- SAP CRM Enterprise Search initial load 遇到错误该如何处理
- abap git - commnication failure错误消息的分析和定位
- JSP常见错误以及解决方案
- mysql 1366的错误 字符集错误解决方案
- 多种方法解决SLF4J: Defaulting to no-operation (NOP) logger implementation的错误
- Failed dependencies: 检查依赖性错误 解决方法
- FPGA-在ISE中错误总结(更新中)
- 操作系统权限提升(九)之系统错误配置-泄露敏感信息提权
- [Git & GitHub] git 常用命令
- [Git & GitHub] Windows安装git和环境变量配置