将主分支重新绑定到一个功能分支上,在重新绑定之后再次发生冲突

将主分支重新绑定到一个功能分支上,在重新绑定之后再次发生冲突

问题描述:

我有一个功能分支,它是前一段时间从主服务器获取的。现在,我要重订主到该功能的分支,所以我做了这个命令:将主分支重新绑定到一个功能分支上,在重新绑定之后再次发生冲突

git rebase master 

然后我SourceTree继续,因为我得到了冲突。我一个接一个地解决了他们,然后继续重新装订,这个过程持续了一段时间。终于非常高兴似乎完成了一切。

这是Sourcetree现在显示我:

enter image description here

当我运行

git rebase master 

我得到

Current branch 2FA is up to date.Current branch 2FA is up to date. 

当我这样做:

git pull 

我得到一个我必须重做的文件列表。

Auto-merging db/schema.rb 
CONFLICT (content): Merge conflict in db/schema.rb 
Auto-merging config/locales/nl.yml 
CONFLICT (content): Merge conflict in config/locales/nl.yml 
Auto-merging app/views/users/_form.html.haml 
CONFLICT (content): Merge conflict in app/views/users/_form.html.haml 
Auto-merging app/models/user.rb 
CONFLICT (content): Merge conflict in app/models/user.rb 
Auto-merging app/models/permission.rb 
CONFLICT (content): Merge conflict in app/models/permission.rb 
Auto-merging app/helpers/application_helper.rb 
CONFLICT (content): Merge conflict in app/helpers/application_helper.rb 
Auto-merging app/controllers/users_controller.rb 
CONFLICT (modify/delete): app/controllers/companies_controller.rb deleted in HEAD and modified in 1110e1f18d4ab388eab767509d95be10b9953a36. Version 1110e1f18d4ab388eab767509d95be10b9953a36 of app/controllers/companies_controller.rb left in tree. 
Auto-merging app/assets/stylesheets/custom.css.sass 
CONFLICT (content): Merge conflict in app/assets/stylesheets/custom.css.sass 
Auto-merging app/assets/stylesheets/backapp.css 
CONFLICT (content): Merge conflict in app/assets/stylesheets/backapp.css 
Auto-merging Gemfile.lock 
CONFLICT (content): Merge conflict in Gemfile.lock 
Auto-merging Gemfile 
CONFLICT (content): Merge conflict in Gemfile 
Automatic merge failed; fix conflicts and then commit the result. 

这是为什么?我已经完成了解决这个问题的工作。这种重组似乎比合并更多的工作。

当您重写了master上的功能分支时,您重写了该分支的历史记录。实际发生的情况是,您在master分支之上重播了您的作品。一旦你完成了底垫中,正常的事情会一直在力推的特性分支到远程:

git push --force origin feature 

,当你做了git pull发生了什么事是你告诉Git的当前远程feature带来分支,大概是通过合并战略。由于您刚刚重写了feature分支,因此Git将远程分支视为“新”,至少就合并应该发生而言。无论如何,做git pull是不正确的,你可能需要的只是强制推送你的功能分支。

如果你想知道为什么你甚至想要在合并时使用rebase,结果是rebase有能力在一个特性分支中保持线性历史记录。这可以是有利的,因为它使得分支的历史容​​易阅读。缺点是每个使用这个分支的人都可能需要通过rebasing来做更多的工作。

+0

太棒了!我做了git merge --abort取消git pull。之后,我做了git push --force来源2FA,但没有给出任何问题。谢谢。 – rept