gpt4 book ai didi

Git merge -s 他们的 : Simply?

转载 作者:IT王子 更新时间:2023-10-29 01:18:56 26 4
gpt4 key购买 nike

我已经检查了关于这个的各种问题。第一个提供a huge question and answer (相关?不确定),第二个提供 wrong answer as best answer.

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

执行此操作的最简单和最容易的方法是什么?

注意:我实际上已经解决了这个问题(使用第三个分支和我们的,但是无论如何这对 SO 来说都是很好的。

最佳答案

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

但是你会发现所有"let's not advertised any "theirs" merging strategy" here .

在用另一个分支工作替换您的工作,或者简单地摆脱当前工作并将其完全替换为另一个分支工作之间,Junio C. Hamano(主要Git Maintainer)更喜欢第二个方法:

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 merge -s 他们的 : Simply?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2303124/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com