如何强制从 git 上的拉取请求进行远程合并?
How to force a remote merge from a pull request on git?
所以我得到了主回购(我们称它为回购 1)和它的一个分支(称为回购 2)。
当所有更改都提交到 repo 2 时,我开始从 2 到 1 的拉取请求,然后尝试在 bitbucket 网站上合并,以便将修改后的文件下载到 repo 1 原始文件所在的服务器,就在那时给出错误:
Bitbucket cannot automatically merge this request due to conflicts.
Review the conflicts on the Overview tab. You can then either decline
the request or merge it manually on your local system using the
following commands:
git checkout master
git remote add danceclub/repo-name ssh://git@bitbucket.org/danceclub/repo-name.git
git fetch danceclub/repo-name
git merge --no-ff -m 'Merged in danceclub/repo-name (pull request #1)' remotes/danceclub/repo-name/master
我遵循了所有内容,当 运行 最后一句话时,它给出了关于合并冲突的冲突警告。最后一句:
Automatic merge failed; fix conflicts and then commit the result.
我该如何解决这个问题?
强制合并?
谢谢
How can I fix this?
运行git status
查看哪些文件有冲突。打开这些文件并找到每个 <<< === >>>
部分。删除你不想要的线并保留你想要的。保存并退出。然后,运行 git add
和 git commit
完成合并。最后,运行 git push
更新远程仓库。
With a forced merge?
Git 有一些 strategies
用于解决冲突。添加选项 --strategy=recursive -X ours/theirs
到 git merge
,ours
保留当前分支的内容,theirs
改为采用其他分支的内容。但实际情况可能并没有这么简单。最好编辑冲突的文件并决定保留哪些行,删除哪些行。
所以我得到了主回购(我们称它为回购 1)和它的一个分支(称为回购 2)。
当所有更改都提交到 repo 2 时,我开始从 2 到 1 的拉取请求,然后尝试在 bitbucket 网站上合并,以便将修改后的文件下载到 repo 1 原始文件所在的服务器,就在那时给出错误:
Bitbucket cannot automatically merge this request due to conflicts. Review the conflicts on the Overview tab. You can then either decline the request or merge it manually on your local system using the following commands:
git checkout master
git remote add danceclub/repo-name ssh://git@bitbucket.org/danceclub/repo-name.git
git fetch danceclub/repo-name
git merge --no-ff -m 'Merged in danceclub/repo-name (pull request #1)' remotes/danceclub/repo-name/master
我遵循了所有内容,当 运行 最后一句话时,它给出了关于合并冲突的冲突警告。最后一句:
Automatic merge failed; fix conflicts and then commit the result.
我该如何解决这个问题?
强制合并?
谢谢
How can I fix this?
运行git status
查看哪些文件有冲突。打开这些文件并找到每个 <<< === >>>
部分。删除你不想要的线并保留你想要的。保存并退出。然后,运行 git add
和 git commit
完成合并。最后,运行 git push
更新远程仓库。
With a forced merge?
Git 有一些 strategies
用于解决冲突。添加选项 --strategy=recursive -X ours/theirs
到 git merge
,ours
保留当前分支的内容,theirs
改为采用其他分支的内容。但实际情况可能并没有这么简单。最好编辑冲突的文件并决定保留哪些行,删除哪些行。