Git Rebase期间的Git Commit - 真正发生了什么? [英] Git Commit during Git Rebase - what really happens?

查看:125
本文介绍了Git Rebase期间的Git Commit - 真正发生了什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



让我们考虑一下,如果在rebase期间提交的话会发生什么情况,以及如何以简单的方式恢复场景,其中大型承诺是重新设计的。重新绑定期间会出现冲突,用户将开始合并更改。
现在,想象一下你几乎已经完成的场景,但是你不会因为什么原因(无论是长周末还是这样)调用。下一个星期,你刚刚恢复工作,在rebase期间继续工作。最后,你调用 git commit --amend 将更改追加到最后一次提交中,并且它们最终放入您要重定向的提交中。



当然,您可以随时检查您开始重新绑定的提交内容和破解你的方式thruogh - 例如,试图从修改中复制所有文件,但这可能会导致引入的更改在此期间。

是否有一个干净的,很好的方法来解决这个问题?这是我应该注意的一个特殊状态,我从不想结束它,但它偶尔也会发生 - 我最终花了整整一天的时间试图让事情顺利。



我会非常感谢所有帮助和建议。谢谢!

解决方案




  • 第一个解决方案是将最终结果重新初始化为原始基础提交。这将需要您再次解决类似的合并冲突,但是当您完成后,您的提交应该回到正轨。


  • 替代解决方案,适用于我将分支出与你所推荐的提交相同的点(它带有SHA,它应该被用作结账基础)。然后创建一个新分支并调用 git merge --no-ff --no-commit --strategy =他们的other_branch ,其中* other_branch *是不幸提交的。



I'm looking for a good description of what happens if one commits during rebase and how this could be 'reverted' in an easy way.

Let's consider a scenario, where a large commit is rebased. During rebase a conflict appears and user begins merging changes. Now, imagine a scenario where you were almost done, but you didn't call git rebase --continue - for whatever reason (be it long weekend or such). The next week you just resumed working, stil during rebase. Finally, you call git commit --amend to append the changes to the last commit and... they end up in the commit you were rebasing into.

Naturally, you can always checkout the commit you started rebasing from and "hack your way thruogh" - say, for example, by trying to copy all the files from your amend, but that may drop the changes that were introduced in the meantime.

Is there a clean, good way to fix this? This is one particular state I should be careful about and I never want to end up in it, but it still happens occasionally - and I end up spending one whole day trying to get things straight.

I would really appreciate all help and suggestions. Thank you!

解决方案

There are two proposed solutions to this situation.

  • The first solution is to rebase final result back onto original base commit. this would require you to resolve similar merge conflicts once again, but when you're done your commit should be back on track.

  • Alternative solution, that worked for me, was to branch off the same point as the commit you ammended to (it carries the SHA, which should be used as a checkout base). Then create a new branch and invoke git merge --no-ff --no-commit --strategy=theirs other_branch, where *other_branch* is the one with unfortunate commit.

这篇关于Git Rebase期间的Git Commit - 真正发生了什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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