如何将我的功能分支重新分配给git中的开发分支,并尽可能避免冲突? [英] How to rebase my feature branch to development branch in git with least possible conflicts?

查看:161
本文介绍了如何将我的功能分支重新分配给git中的开发分支,并尽可能避免冲突?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的功能分支已超过30或更多的提交。与此同时,在开发分支中,其他功能已经被其他开发者推动了。因此,每次发布新功能时,都会被要求:


  1. 在我的功能分支上重新开发分支

  2. 解决冲突(如果有的话)
  3. 在您的功能分支中继续开发

问题



第二步是鸡的脖子。在重新绑定时,它会为该分支的每个提交提供冲突。这实际上是迭代和多余的。请注意,由于我在分支中的工作仍在进行中,因此无法立即重新绑定开发分支。



我试过了什么?


  1. squash 并尽可能减少我的提交(但这最少帮助,因为大多数时候没有什么可压缩的)

  2. stash 我正在进行更改,并重新绑定开发,然后取消更改我的更改。 (但在这里,我也遇到冲突)

  3. 使用 -preserve-merges 和rebase。 (但是这里的每个人都大声说使用这个是完全不鼓励的)

那么,什么是最佳方法在功能分支本身有很多提交时处理将功能分支重新分配到功能分支时冲突最少。我是一个新鲜的人,所以一个有帮助的解释(或链接)的答复将有很大的帮助。

工作流程是完美的(rebase)。

但冲突不应该一次又一次得到解决。



为此,您有< a href =https://git-scm.com/docs/git-rerere =noreferrer> git rerere :激活它( git config --global rerere.enabled true ),最后一次解决冲突(或者执行手动重新培训使用 contrib / rerere-train.sh ),你的下一个rebase会在你下一次rebase时重新使用这些冲突解决方案。


I have my feature branch which has exceeded around 30 or more commits. Meanwhile in development branch few other features have been pushed from other developers. Therefore, Everytime a new feature is published on development, I am asked to:

  1. Rebase development branch onto my feature branch
  2. Resolve conflicts if any
  3. Continue developing in your feature branch

The problem

The second step is the chicken's neck here. On rebasing it gives me conflicts for every commit of that branch. This is really iterative and redundant. Note, I can't always rebase the development branch immediately since my own work in my branch remains in progress.

What I tried?

  1. To squash and reduce my commits as much as possible (but this helps least, as most of the times there is nothing to squash)
  2. To stash my on going changes, and rebase development and then unstash my changes. (but here, I get conflicts as well)
  3. Using -preserve-merges with rebase. (but everyone here shouts that using this is totally discouraged)

So, what is the optimal approach in dealing with rebasing development onto feature branch with least conflicts when the feature branch itself has numerous commits. I am a fresher, and so a reply with a helpful explanation (or link) will be of much help to proceed.

解决方案

The workflow is sound (rebase).
But the conflicts should not be resolved every time over and over again.

For that, you have git rerere: activate it (git config --global rerere.enabled true), resolve the conflict one last time (or do a manual re-training, or use contrib/rerere-train.sh), and your next rebase will resuse those conflict resolution at your next rebase.

这篇关于如何将我的功能分支重新分配给git中的开发分支,并尽可能避免冲突?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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