您好,欢迎来到伴沃教育。
搜索
您的当前位置:首页前端|git merge origin/branchname

前端|git merge origin/branchname

来源:伴沃教育

因为在一个gitlab仓库A中放了两个项目,并且耦合性特强,leader新建了一个仓库B,并且将仓库A中的东西原封不动的搬到了仓库B,包括分支.

然后leader从develop分支做了大量修改,push到了远程分支,同学们,问题来了,,,,,当我clone这个项目到本地的时候,默认分支是master呀,此时我创建本地develop分支是以develop为基础的,我试图通过git pull来使本地develop和远程develop同步,but  but 不行,老提示一下问题,confused~~~

ok,CONFLICT,并且此时我的git 的head已处在了游离状态....

看到这些提示,我的内心是崩溃的,什么鬼

然后我试图git checkout develop

提示我

```

Switched to branch 'develop'

Your branch and 'origin/develop' have diverged,and have 8 and 2 different commits each, respectively

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

```

然后我又乖乖git pull,然后把上边的流程又走了一遍,同样的操作同样的提示,are you kidding me ?

其实问题出在 `Your branch and 'origin/develop' have diverged,and have 8 and 2 different commits each, respectively`

*************************我是华丽的分割线*****************************

上次没有解决实际问题,用leader的话说,我总喜欢绕开问题

其实对于上边的问题,我只需要

1.fix conflict

2.git add .

3.git rebase --continue

就ok了

*************************我是华丽的分割线*****************************

我们也可以换种思路:

1.以远程的develop分支来创建本地分支(滑稽可笑)

2.在master分支的基础上来创建develop分支,然后将远程的develop分支merge到我本地的develop分支

查了查文档,第二种可行,我查到了伟大的 

`git merge origin/develop`

它的作用就是将origin上的develop分支merge到当前的develop分支上

问题完美解决,ps : `git merge origin master`是将当前分支的远程分支merge到master 上

最上边出现的一系列问题,我还有点迷茫,是我绕开了

不知道我的解决问题的思路是不是可以更优化一下,望批评指导

Copyright © 2019- bangwoyixia.com 版权所有 湘ICP备2023022004号-2

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务