当前位置:   article > 正文

Git常见问题:Your branch and ‘xxx/xxx‘ have diverged_your branch and have diverged

your branch and have diverged

报这个错就是因为你和远程库出现分叉了,具体表现是是由于同一个分支有多人修改,多人commit造成的

用户1操作

用户2操作

T1

git co -b brv_1

git co -b brv_1

T2

git add test2.java

git commit -m 'm2'

git push

T3

git add test1.java

git commit -m 'm1'

git push

Your branch and 'XXX' have diverged,

and have 1 and 1 different commits each, respectively.

(use "git pull" to merge the remote branch into yours)

T4

git pull

fatal: Not possible to fast-forward, aborting.

问题:T3时刻,提示用户git push之前需要先进行一下git pull,然而在T4时刻执行git pull时又阻止了这一操作

解决方式一:T4时刻执行git pull之前执行一下 git rebase即可

解决方式二:T4时刻执行 git push -f ,丢弃掉其它人的的修改(不推荐)

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/盐析白兔/article/detail/559086
推荐阅读
  

闽ICP备14008679号