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

复制代码
➜  git:(test) git pull origin test
 * branch              test       -> 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 (the default strategy)
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:(test) git pull origin test
  提示:您有不同的分支,需要指定如何协调它们。
  提示:您可以通过在之前某个时间运行以下命令之一来做到这一点
  提示:你的下一招:
  提示:
  提示:git config pull.rebase false 	# 合并(默认策略)
  提示:git config pull.rebase true  	# Rebase
  提示:git config pull.ff only	 	# 仅快进
  提示:
  提示:可以将"git config"替换为"git config------global"来设置默认值
  提示:首选所有存储库。你也可以传递------rebase,------no-rebase,
  提示:或命令行上的------ff-only,以覆盖配置的默认per
  提示:调用。
  fatal:需要指定如何协调不同的分支。

2. 解决方法

分析:这是由于你拉取pull分支前,进行过merge合并更新分支操作,而其他人在你之前已经push过一个版本,导致版本不一致

第一种解决方法:比较简单

  • 执行git config pull.rebase false

  • 默认将pull下来的代码与现有改动的代码进行合并

  • 但是可能会造成代码冲突,需要处理下这个问题,代码冲突如果2个人都改了同一个文件,需要联系之前push的同学,看看这块代码怎么保存

  • 根据历史版本记录,选择commit地址,回退到自己合并之前的版本

    ➜ git:(test) git reset --hard 33df706e780d10af6435bda1fee85430604eebfd

    再进行pull更新分支

    ➜ git:(test) git pull origin test

    最后再重新合并代码

    ➜ git:(test) git merge dev

    记得养成一个良好git发布流程的习惯

    复制代码
    # 分支合并发布流程:
    git add .            # 将所有新增、修改或删除的文件添加到暂存区
    git commit -m "版本发布" # 将暂存区的文件发版
    git status             # 查看是否还有文件没有发布上去
    git checkout test    # 切换到要合并的分支
    git pull            # 在test 分支上拉取最新代码,避免冲突
    git merge dev       # 在test 分支上合并 dev 分支上的代码
    git push            # 上传test分支代码

    更多git操作请查看博主的另一篇文章,关注我不迷路,我替你们把坑都踩平了:

相关推荐
YANZ22223 分钟前
亚马逊绿标(CPF):从环保认证到跨境流量新引擎
java·大数据·人工智能·搜索引擎·百度
Elastic 中国社区官方博客1 小时前
Elasticsearch percolator 用于电商搜索治理:将模糊查询转换为可控的检索策略
大数据·数据库·人工智能·elasticsearch·搜索引擎·ai·全文检索
shamalee1 小时前
Gemini3.1Pro:2026招聘效率革命
大数据·人工智能
逸Y 仙X1 小时前
文章二十二:ElasticSearch EQL事件查询语言
java·大数据·elasticsearch·搜索引擎·全文检索
icestone20001 小时前
智能客服如何按客户类型切换话术?一套支持“渠道标签 + 用户自选 + 对话推断“的分类架构设计
大数据·人工智能·ai编程
前端之虎陈随易2 小时前
为什么今天还会有新语言?MoonBit 想解决什么问题?
大数据·linux·javascript·人工智能·算法·microsoft·typescript
南棱笑笑生2 小时前
20260505在小米13Ultra下给微信通话录音
搜索引擎
发哥来了2 小时前
东莞AI培训课程横向对比:五家机构教学与就业质量评测
大数据·人工智能·机器学习·ai·aigc
摇滚侠2 小时前
ElasticSearch 在电商项目的作用 全文检索 自动补全 聚合查询 按距离排序
大数据·elasticsearch·全文检索
计算机毕业编程指导师2 小时前
【Python大数据项目推荐】基于Hadoop+Django脑卒中风险分析系统源码解析 毕业设计 选题推荐 毕设选题 数据分析 机器学习 数据挖掘
大数据·hadoop·python·计算机·spark·毕业设计·脑卒中