混帐合并操纵历史 [英] git merge manipulates the history

查看:72
本文介绍了混帐合并操纵历史的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我们的团队中,常规过程是当我们有一个重要特性时,我们在一个功能分支上工作。

现在和之后 - 我们从 master 结束功能分支,当我们准备好时 - 我们会合并回到 master (通常通过一个pull request)。



问题在于合并后提交历史是混合的 - 我们没有简单的方法来回退分支合并操作,以排除分支,以防发生问题。 p>

我们正在考虑一些替代方案:


  1. 功能分支 - 重新分支 master 之上的分支,以便功能提交出现在日志的最后。

    这会减轻它的移除,但我们如果有人不遵守这个规则,那么它仍然存在同样的问题)

  2. 不是将分支合并回主模块,而是重新绑定特性分支它。这可能意味着我们不能再使用pull请求了。
  3. 每天都有一个脚本标记master。

    由于我们需要排除已经合并的分支是非常罕见的 - 我们可以从昨天开始逐一检查和考虑提交。这听起来很不起眼,但它并不妨碍我们目前在这里做的事情。

  4. 在这里练习吗?

    解决方案


    而不是将分支合并回主模块 - 重新绑定顶部的特性分支的。这可能意味着我们不能再使用拉请求了。


    是的,您可以使用PR,重新分支到您的分叉。

    一个请求可以跟随分支历史的多次重写。



    请注意1非常相似2在这里:重新分配主分支与重新分配顶部的分支(主)。



    但是无论如何,掌握之前是PR之前的首选工作流程。


    In our team, the regular procedure is that when we have a significant feature we work on a feature branch.
    Every now and then - we merge from master to out feature branch and when we're ready - we merge back to master (usually through a pull request).

    The problem is that as after the merge the commits history are mixed - we don't have a simple way to role back the branch-merging operation, to exclude the branch in case we find it problematic.

    We were considering a few alternatives:

    1. instead of merging master to the feature branch - rebase the branch on top of master, so that the feature commits appear last in the log.
      This would ease it removal but we're still in the same problem if someone didn't follow this rule)

    2. Instead of merging the branch back to master - rebase the feature branch on top of it. this will probably mean we can no longer use pull requests.

    3. Have a script tag master daily.
      As the occasions we need to exclude an already merged branch are very rare - we can probably examine and consider the commits since yesterday one by one. this sounds very hacky but it doesn't stand in the way we currently do things in here

    What is the best practice here?

    解决方案

    instead of merging the branch back to master - rebase the feature branch on top of it. this will prםbably mean we can no longer use pull requests.

    Yes, you will be able to use the PR, after force pushing your rebased branch to your fork.
    A pull-request is able to follow multiple rewrite of a branch history.

    Note that 1 is strangely similar to 2 here: "rebase the branch on top of master" vs. "rebase the feature branch on top of it (master)".

    But in any case, rebasing feature on top of master is the prefered workflow before a PR.

    这篇关于混帐合并操纵历史的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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