问题描述
我已经查看了有关此的各种问题.第一个提供了一个巨大的问答(相关?不确定),第二个提供了 错误答案作为最佳答案.
I have checked out the various questions on this. The first provides a huge question and answer (relevant? not sure) and the second provides a wrong answer as best answer.
我有一个名为 great-use-this
的分支.我有另一个名为 master
的分支.我想将 great-use-this
合并到 master 中,避免自动合并冲突.
I have a branch called great-use-this
. I have another branch called master
. I want to merge great-use-this
into master, and avoid auto-merging conflicts.
最简单、最简单的方法是什么?
推荐答案
是的,创建第三个分支并执行 merge -s ours
是一种解决方案.
Yes, creating a third branch and doing a merge -s ours
is one solution.
但是您会在此处找到所有我们不要在此处宣传任何他们的"合并策略".
But You will find the all "let's not advertised any "theirs" merging strategy" here.
在用其他分支工作替换您的工作之间,或者干脆摆脱当前工作并将其完全替换为另一个,Junio C. Hamano(主要 Git 维护者)更喜欢第二种方法:
Between replacing your work with one other branch work, or simply getting rid of the current work and replacing it completely by the other one, Junio C. Hamano (main Git Maintainer) prefers the second approach:
我认为-s theirs
"更糟.这就是您放弃所做的事情的方式(也许是因为另一方的解决方案比您的 hack 好得多),但这可以更轻松、更干净地完成:
$ git reset --hard origin/master
有些人可能会说但是使用 'merge -s theirs
',我也可以保留我所做的事情".重置只是放弃我所做的.
Some people might say "But with 'merge -s theirs
', I can keep what I did, too". That reset is simply discarding what I did.
这个逻辑也是有缺陷的.您可以改为:
That logic also is flawed. You can instead:
$ git branch i-was-stupid
$ git reset --hard origin/master
如果你真的想记录你的失败.
if you really want to keep record of your failure.
-s theirs
"的一个大问题,与上面的重置到原点,丢弃或搁置失败的历史"相比,你的主"历史是你进一步开发是基于如果你做了-s theirs",将永远保留你失败的废话.
One big problem "-s theirs
" has, compared to the above "reset to origin, discarding or setting aside the failed history" is that your 'master' history that your further development is based on will keep your failed crap in it forever if you did "-s theirs".
希望随着时间的推移你会成为一个更好的程序员,你最终可能会在你的 master 分支的尖端附近有一些值得与世界分享的东西.然而,当这种情况发生时,你不能提供你的主分支由上游拉取,因为更广泛的世界根本不会对你之前的错误感兴趣.
Hopefully you will become a better programmer over time, and you may eventually have something worth sharing with the world near the tip of your master branch. When that happens, however, you cannot offer your master branch to be pulled by the upstream, as the wider world will not be interested in your earlier mistakes at all.
这篇关于Git 合并 -s 他们的:简单吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!