git rebase后发生新提交时该怎么办? [英] What to do when new commits happen after a git rebase?

查看:321
本文介绍了git rebase后发生新提交时该怎么办?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚完成了一个特别繁琐的基础工作(有人在分支机构工作了数周而从未进行过基础调整.)我花了大约两三个小时,因为我使用的人类可读"格式只是一堆ID和参考.

I just got done with a particularly hairy rebase (someone worked for weeks on a branch without ever rebasing.) It took me about two or three hours because the "human readable" format that I was using is just a bunch of IDs and references.

在执行此基准时,在我有机会git push基准结果之前,分支上又出现了两次提交.

While I was doing this rebase, two more commits showed up on the branch before I had the chance to git push the result of the rebase.

是否有最佳实践来获取这些新提交而无需重新做基础或求助于合并?我最初的想法是我可以git cherry-pick这些新的提交,然后git push -f,但是那样不好吗?

Is there a best practice for getting those new commits without re-doing the rebase or resorting to a merge? My initial thought was that I could git cherry-pick those new commits and git push -f, but would that be unsavory?

推荐答案

您应该能够再次对提交进行重新设置.

You should be able to rebase your commits again.

唯一的问题是,您必须重新制定冲突解决方案,因为您没有激活 git rerere .

The only issue is that you will have to remake your conflict resolutions, because you did not activate git rerere.

好吧,...不必使用您是否还愿意?" 特里斯坦·罗素:

Well,... you don't have to, with the rerere-train.sh script.
See "Do you even rerere?" by Tristan Roussel:

以最简单的形式,脚本从您指定的提交开始,并遍历每个父提交以查找冲突.

In this simplest form, the script starts from the commit you specified and go through every parent commit to look for conflicts.

这将使您能够记录过去的冲突解决方案,并在无需再次进行操作的情况下重新定基.

That will allow you to record those past conflict resolutions, and rebase again without having to do them again.

这篇关于git rebase后发生新提交时该怎么办?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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