【Git】Git pull代码时,出现报错:hint: you have divergent branches and ...

打印 上一主题 下一主题

主题 857|帖子 857|积分 2571

问题描述

在执行 git pull 时,出现了如下提示:
  1. ➜  git:(test) git pull origin develop
  2. * branch              develop       -> FETCH_HEAD
  3. hint: You have divergent branches and need to specify how to reconcile them.
  4. hint: You can do so by running one of the following commands sometime before
  5. hint: your next pull:
  6. hint:
  7. hint:   git config pull.rebase false  # merge (the default strategy)
  8. hint:   git config pull.rebase true   # rebase
  9. hint:   git config pull.ff only       # fast-forward only
  10. hint:
  11. hint: You can replace "git config" with "git config --global" to set a default
  12. hint: preference for all repositories. You can also pass --rebase, --no-rebase,
  13. hint: or --ff-only on the command line to override the configured default per
  14. hint: invocation.
  15. fatal: Need to specify how to reconcile divergent branches.
复制代码

原因分析:

   先翻译下提示的信息:
gitdevelop) git pull origin develop
提示:您有差别的分支,须要指定如何协调它们。
提示:您可以通过在之前某个时间运行以下命令之一来做到这一点
提示:你的下一次获取:
提示:
提示: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:须要指定如何协调差别的分支。
  原因:由于你在pull代码之前,进行了merge并更新代码的操作,而其他人在你之前提交了一个版本,导致版本不一致。

办理方案:



  • 方案一:

    • 按照提示,直接执行git config pull.rebase false
    • 该操作是默认获取最新代码,并与当地合并,如果有冲突,须要办理冲突。

  • 方案二:

    • 该方法实用于两个分支的合并
    • 先保存下修改内容,然后将当前分支回退到修改代码之前的版本,执行pull以获取最新代码
    • 然后将要合并的分支合并到当前分支,再将自己的改动添加上,
    • 最后再提交接码


免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

立聪堂德州十三局店

金牌会员
这个人很懒什么都没写!
快速回复 返回顶部 返回列表