整理一个Git混乱 [英] Sorting out a Git mess

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

问题描述

我刚刚继承了一个使用Git维护的项目。在某一时刻,代码被部署到3个独立的系统上,每个系统都维护着他们自己的分散的Git仓库。



这三个系统中的每一个都将原始基本系统扩展为3种不同的方向。这三个系统中没有一个是相互同步的。



如何将3个不同的来源放在一起,以便我可以:


  1. 找到一个共同的基础来处理;
  2. 找出哪些更改是应该应用于所有3个系统的错误修复;和

  3. 以一种合理的方式维护3个系统,以便只有一个公共分支并将3个不同系统所需的自定义分离出来

  4. 我可能会先推送所有的存储库,以便在中央存储库中分离分支,从中可以分支和合并等分支很容易。



    一个很好的可视化工具,如 git-age gitnub gitx 咯咯可以工作奇迹,但你的任务可能会相当乏味,除非你能找到分支点。如果有类似的补丁应用于所有分支,您可以使用(交互式)重新绑定重新排序您的提交以便它们的顺序相同。然后你可以开始拉紧你的分支,通过将提交提交给主分支向上移动分支点。关于如何使用rebase重新排序提交的一个很好的描述可以发现这里



    您需要采取的措施的机会在 Git Howto Index 。一个很好的备忘单总是很好的达到。另外,我怀疑Eric Sinks发布的后续内容是 DVCS和DAG,第1部分将包含一些有用的东西(它没有,但是是一个有趣的阅读nontheless)。



    其他好的链接是: Git Magic Git Ready SourceMage Git指南



    我希望所有的回购都有很好的提交信息,告诉你每个补丁的目的,就是这个或者代码审查:)

    至于如何维护定制我们有幸运用了以下内容:



    我们从定制代码与通用代码分离(或保持独立)开始。然后我们尝试了两种方法;这两个工作都很好:


    1. 所有部署都拥有自己的存储库,用于定制。

    2. 所有部署都在定制存储库中获得了自己的分支。

    在第一次部署并看到第二个是事实后,花了一些时间试图预见未来的定制/切割点,以减少定制回购(我们目前使用的方法,也就是我们目前使用的方法)和基本/核心回购中的重复。

    是的,当我们注意到核心/自定义分裂滑动时,我们确实试图无情地重构:)


    I've just inherited a project which was maintained using Git. At one point, the code was deployed onto 3 separate systems and each system maintained their own decentralised Git respository.

    Each of the 3 systems extended the original base system in 3 different directions. None of the 3 systems have been synchronised against each other. Some changes are on master branch, others are on new branches.

    How can I bring the 3 different sources together so that I can:

    1. find a common base to work with;
    2. find out which changes are bug fixes which should be applied across all 3 systems; and
    3. maintain the 3 systems in a sane way so that there is only one common branch and separate out the customisations required for the 3 different systems?

    解决方案

    I would probably start by pushing all the repositories to separate branches in a central repository, from which I can rebase, merge etc between branches easily.

    A good visualization tool such as git-age, gitnub, gitx, giggle can work wonders, but your task will probably be rather tedious unless you can find the branching points. If there are similar patches applied to all branches you can use (interactive) rebase to reorder your commits such that they are in the same order. Then you can start 'zipping up' your branches, moving the branch-point upwards by putting commits into master. A nice description on how to reorder commits using rebase can be found here.

    Chances are the actions you need to take are described in the links provided by the Git Howto Index. A good cheat sheet is always nice to have within reach. Also, I suspect the followup to Eric Sinks post "DVCS and DAGs, Part 1" will contain something useful (It didn't, but was an interesting read nontheless).

    Additional good-to-have links are: Git Magic, Git Ready and SourceMage Git Guide

    I hope all the repos had good commit messages that tell you the purpose of each patch, it's that or code review :)

    As for how to maintain customizations we've had luck with the following:

    We started by separating (or keeping separate) the customized code from the generic code. Then we've tried two approaches; both which worked fine:

    1. All deployments got their own repositories where the customization was kept.
    2. All deployments got their own branch in a 'customization'-repository.

    After the first deployment and seeing that the second was a fact we spent some time trying to foresee future customization/cutting points to reduce duplication across the customized repos (alt. 1, which is the approach we currently use) and in the base/core repo.

    And yes, we do try to refactor mercilessly whenever we notice the core/customization split slipping :)

    这篇关于整理一个Git混乱的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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