替代git rebase [英] Alternative to git rebase

查看:88
本文介绍了替代git rebase的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是git的新手。
比方说,我从远程本地分发了一个存储库,它被称为localRepo。有两个分支Master和testBranch。 testBranch提前100次提交并提交5000次提交。对testBranch进行了更改,但从未合并到Master中。所以我想把testBranch放到我分叉的localRepo的master上。



我做了以下工作:


  1. git checkout testBranch

  2. git fetch origin
  3. git rebase origin / Master

我正在经历多次冲突, mergetool(kdiff3),并说明删除或修改了哪些文件等等。

由于它落后5000次左右,是否有可能发生更多冲突?如果我像这样手动解决冲突,我想知道需要多少天!这将是非常乏味和不切实际的。



我是否以正确的方式进行操作?

这是此场景的唯一方法吗?或者其他有效的方式?

解决方案

不,没有其他选择。就是这样。获得的经验:早日兑现,经常兑现。落后于提交意味着你迟早会浪费很多时间。两年前,我编写并合并了一个200个提交功能的分支,这个分支是在六个月的时间内开发的。我不知道在这六个月内合并了多少次提交。但我相信他们也有成千上万的数字。如果我等到我完成我的特色分支,并试图重新绑定,我会遇到很大的麻烦。但我每天都会重新启动,最终的合并变成了一个大而胖的汉堡。



如果功能分支中的数百次提交可以逻辑分成小块,有可能将分块分成几个阶段。如果你的特性分支的一百个提交中有几个主要的检查点,并且在每一点你的功能分支都是全功能和可测试的,那么你可以考虑只提交所有提交到检查点的提交,然后对这些提交进行重新绑定,然后测试它们。然后,一旦你测试了你的提交的初始块在rebase之后工作,继续和rebase提交,直到下一个检查点。



当你在一旦git只会在每次失败重置的提交时停止。至少这样你可以更好地控制这个过程。您可以在预先设定的检查点停下并暂停,然后对重新设置的更改进行广泛的回归测试,然后继续。



请注意,为了您的工作,在跟踪你的特性分支上的所有提交时是完美的;哪一个已经重新设计,哪些没有。

I am new to git. Let's say, I have forked a repository locally from remote, and it is called localRepo. There are two branches Master and testBranch. testBranch is 100 commits ahead and 5000 commits behind. Changes were made to testBranch but never incorporated to Master. So I wanted to rebase testBranch onto master in my forked localRepo.

I did the following:

  1. git checkout testBranch
  2. git fetch origin
  3. git rebase origin/Master

I am experiencing several conflicts and I am solving it by hand using mergetool (kdiff3) and by saying which deleted or modified file to use etc...

Since it is around 5000 commits behind, are there possibilities for more conflicts to occur? If i resolve conflicts manually like this, I wonder how many days would it take! It would be very tedious and unpractical.

Am I doing it in the right way?

Is this the only way for this scenario? Or any other efficient way?

解决方案

No, there is no alternative to rebase. It is what it is. Lesson learned: rebase early, and rebase often. Getting behind on your commits means that you are going to waste a lot of time, sooner or later. Two years ago I wrote and merged a 200-commit feature branch, that was developed over the course of six months. I don't know how many commits were merged during those six months. But I'm sure that they also numbered in the thousands. Had I waited until I finished my feature branch, and tried to rebase, I'd be in big trouble. But I rebased daily, and the eventual merge turned out to be a big, fat, nothing-burger.

If the hundred or so commits in your feature branch can be logically divided into small chunks, it might be possible to divide the rebase into phases. If you have several major checkpoints across your feature branch's hundred commits, and at each point your feature branch is fully-functional and testable, you might consider taking all the commits up to the checkpoint only, and then rebase just those, and then test them. Then, once you've tested that the initial chunk of your commits are working after the rebase, proceed and rebase the commits until the next checkpoint.

When you rebase everything at once, git will stop only at each commit that fails to rebase. At least this way you have more control over the process. You can stop, and pause, at predetermined checkpoints and do a extensive regression test on the rebased changes, then proceed.

Note, however, that for this to work you have to be perfect in keeping track of all the commits on your feature branch; which one have been rebased, and which ones haven't.

这篇关于替代git rebase的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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