Git合并 - 他们的:简单? [英] Git merge -s theirs: Simply?

查看:88
本文介绍了Git合并 - 他们的:简单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经检查了关于这个的各种问题。第一个提供了一个巨大的问题和答案(相关?不确定),第二个提供了错误答案作为最佳答案。



我有一个名为 great-use-this 的分支。我有另一个名为 master 的分支。我想将 great-use-this 合并到master中,并避免自动合并冲突。



什么是最简单最简单的方法?

注意:我已经想到了这一点(使用第三个分支和我们的),但是无论如何,

解决方案

是的,创建第三个分支并执行 merge -s our 是一个解决方案。



但是你会发现所有让我们不要在这里公布任何他们的合并策略



在将工作替换为另一个分支工作或简单地删除当前工作和完全由另一个Junio C. Hamano(主要 Git Maintainer a>)更喜欢第二种方法:


我认为 -s他们的更糟糕的是,你将如何抛弃哟你做了(也许因为对方有比你的黑客更好的解决方案),但是可以更容易和干净地完成:

  $ git reset --hard origin / master 

有些人可能会说但用' code>合并它们',我也可以保留我所做的。这个重置只是放弃了我所做的。



这个逻辑也是有缺陷的。你可以改为:

  $ git分支i-was-stupid 
$ git reset --hard origin / master

如果您确实想记录您的失败。

与上述重置原点,丢弃或设置相比,一个大问题 - 他们的除了失败的历史,你的'主'历史,你的进一步发展所依据的将永远保持你失败的废话,如果你做了 - 他们。



希望随着时间的推移,你会成为一个更好的程序员,并且你可能最终会在你的主分支的尖端附近有一些值得与世界分享的东西。然而,当这种情况发生时,你不能让你的主分支被上游拉动,因为更广泛的世界根本不会对你以前的错误感兴趣。



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.

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.

What is the simplest and easiest way to do this?

Note: I have actually figured this out (using a third branch and ours, but this would be good to have on SO anyway.

解决方案

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.

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:

I think "-s theirs" is even worse. It is how you would discard what you did (perhaps because the other side has much better solution than your hack), but that can be much more easily and cleanly done with:

$ git reset --hard origin/master

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.

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".

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合并 - 他们的:简单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆