git拉取时报错

报错如下

git -c diff.mnemonicprefix=false -c core.quotepath=false --no-optional-locks fetch --no-tags origin

From https://gitee.com/erzhan/qgisdemo

d7c043e...c9e341f master -> origin/master

git -c diff.mnemonicprefix=false -c core.quotepath=false --no-optional-locks pull origin master

From https://gitee.com/erzhan/qgisdemo

  • branch master -> FETCH_HEAD

hint: You have divergent branches and need to specify how to reconcile them.

hint: You can do so by running one of the following commands sometime before

hint: your next pull:

hint:

hint: git config pull.rebase false # merge

hint: git config pull.rebase true # rebase

hint: git config pull.ff only # fast-forward only

hint:

hint: You can replace "git config" with "git config --global" to set a default

hint: preference for all repositories. You can also pass --rebase, --no-rebase,

hint: or --ff-only on the command line to override the configured default per

hint: invocation.

fatal: Need to specify how to reconcile divergent branches.

原因:

这个错误是 Git 2.27+ 版本的新特性,它不再默认选择合并策略,而是要求你明确指定如何处理分歧的分支。下面提供两种最常用的解决方案:

解决:

在命令终端执行

git config --global pull.rebase false,意思是设置全局默认使用 merge 方式(最常用、最安全)

之后再正常拉取即可

相关推荐
lifewange33 分钟前
常用的Git命令有哪些?
git
无限进步_1 小时前
【C++】电话号码的字母组合:从有限处理到通用解法
开发语言·c++·ide·windows·git·github·visual studio
专注API从业者1 小时前
淘宝商品详情 API 与爬虫技术的边界:合法接入与反爬策略的技术博弈
大数据·数据结构·数据库·爬虫
V搜xhliang02461 小时前
AI大模型在临床决策与手术机器人领域的应用
大数据·人工智能·机器人
C++ 老炮儿的技术栈1 小时前
GCC编译时无法向/tmp 目录写入临时汇编文件,因为设备空间不足,解决
linux·运维·开发语言·汇编·c++·git·qt
英俊潇洒美少年1 小时前
Git 常用命令速查表(前端开发专属版)
git
A__tao1 小时前
Elasticsearch Mapping 一键生成 Proto 文件(支持嵌套 + 注释过滤)
大数据·elasticsearch·jenkins
Devin~Y2 小时前
高并发电商与AI智能客服场景下的Java面试实战:从Spring Boot到RAG与向量数据库落地
java·spring boot·redis·elasticsearch·spring cloud·kafka·rag
Gofarlic_OMS2 小时前
装备制造企业Fluent许可证成本分点典型案例
java·大数据·开发语言·人工智能·自动化·制造