fatal: Need to specify how to reconcile divergent branches.

报错

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给出的,旨在帮助你决定如何处理分叉的分支,在你下一次执行git pull操作时如何合并这些更改。当本地分支和远程分支有不同的提交历史时,就会出现分叉,这通常发生在别人已经推送了一些提交到远程仓库,而你的本地仓库还没有这些更新。

Git提供了三种策略来解决这个问题:

1. 合并(Merge)

  • 命令git config pull.rebase false
  • 描述:这会在执行git pull时合并远程分支的更改。如果有冲突,需要手动解决。这是默认策略。

2. 变基(Rebase)

  • 命令git config pull.rebase true
  • 描述:这会在拉取远程分支的更改之前,先将你本地的更改移至远程分支的顶部。这样可以保持项目历史的线性。

3. 快进(Fast-forward)

  • 命令git config pull.ff only
  • 描述:只允许快进合并。如果git pull操作不能通过快进完成(即需要合并或变基来解决分叉),这个命令会导致失败。

为了设置所有仓库的默认拉取策略,你可以使用--global标志

git config --global pull.rebase false
 

  • 5
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值