简体   繁体   English

合并冲突与请求请求

[英]merge conflict with pull request

I'm new git! 我是新来的git! I try contributing to a project user2:master, and make a pull request. 我尝试为项目user2:master做出贡献,并提出拉取请求。 Then I needed to fix something, so I did. 然后我需要修复一些问题,所以我做到了。 I made the change, push to my master branch user1:master. 我进行了更改,将其推送到主分支user1:master。 So now, 2 commits are seating in the pull request. 因此,现在有2个提交位于pull请求中。 user2 wants to merge my commits, but there's a merge conflict. user2想合并我的提交,但是存在合并冲突。 How do can I merge these conflicts? 如何合并这些冲突? (I think theres a conflict between the first and second commit). (我认为第一次提交和第二次提交之间存在冲突)。 Thank you in advance 先感谢您

Difficult to say for sure without knowing more about the conflict, but the most likely reason that user2 is running into a merge conflict is he/she made some change which conflicts with your change after your last pull of the upstream (user2) repo. 在不了解冲突的情况下很难确定地说,但是user2遇到合并冲突的最可能原因是他/她做了一些更改,这与您上次拉动上游(user2)回购后的更改相冲突。

The usual way to deal with this, assuming the other user hasn't merged your pull request yet is: 假设其他用户尚未合并您的拉取请求,通常的处理方法是:

  1. Rebase your changes on top of the latest in user2:master, eg git fetch user2; git rebase user2/master 在user2:master中的最新内容基础上进行更改,例如git fetch user2; git rebase user2/master git fetch user2; git rebase user2/master
  2. This will likely cause a merge conflict. 这可能会导致合并冲突。 Resolve the conflict in the indicated files, test, then do git add <those files>; git rebase --continue 解决指示文件中的冲突,进行测试,然后执行git add <those files>; git rebase --continue git add <those files>; git rebase --continue
  3. Finally, carefully push your newly rebased commits back to your remote branch to update the pull request (you'll have to use --force, since you've technically rewritten those commits, so make sure only to do this if the other user has not merged your request yet) git push user1 master --force 最后, 小心地将新近重新提交的提交推回远程分支以更新拉取请求(由于技术上已经重写了这些提交,因此必须使用--force,因此请确保仅在其他用户具有尚未合并您的请求) git push user1 master --force

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM