如何管理一个项目的多个版本? [英] How to manage multiple versions of a project?

查看:369
本文介绍了如何管理一个项目的多个版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用git进行版本控制的开源项目.不久,我还将发布该项目的高级托管版本,但是将专门针对高级托管版本的代码(性能等)进行更改,而这些更改在开源版本中将不存在. /p>

我要避免有两个单独的目录/项目,因为如果修复开放源代码版本中的错误,则该错误也很可能也出现在高级托管版本中.我不想在两个地方进行更改.

管理此问题的最佳方法是什么?仅仅分支到git是行不通的,因为某些文件需要具有2个版本:开源版本和高级托管版本.

解决方案

但是,分支应该可以工作,并且允许您维护两个单独的版本.

如果您有一个适用于高级版本的错误,请在master上进行修复,然后在premium分支上进行合并.
Git只会合并自您在masterpremium之间分支以来发生的变化,即您的错误修复.
masterpremium中同时发布修补程序的另一种方法是从共同祖先处执行此操作:请参阅" Git合并多个分支的修补程序".


2015年更新:git 2.5(2015年7月)已用新命令git-new-workdir. txt#L228-L233"rel =" noreferrer> git worktree add <path> [<branch>] .

有关更多信息,请参见" 使用Git的多个工作目录? ".


2012年原始答案:

me-and /how-to-manage-multiple-versions-of-a-project-in-git/12153522#comment16269524_12153522>评论命令 使用分支机构使用git-new-workdir "

  • "核鱿鱼git-new-workdir "
  • 一个解决方案是简单地创建存储库的另一个本地克隆.在本地克隆时,Git自动使用硬链接,因此克隆非常快.
    但这有一个问题:您现在需要另一个单独的存储库,以保持最新状态.

    这是git-new-workdir出现的地方.
    无需为您的存储库进行全面的克隆,它只是为您设置了一个新的工作目录(具有自己的索引).
    实际存储库本身在原始工作目录和新工作目录之间共享.这意味着:

    • 如果更新一个存储库,则新的提交也将立即在所有其他工作目录中可见.
    • 在您的一个工作目录中创建一个新的提交或分支,它们立即在所有工作目录中可用.

    注意:即使提交是自动存在的,但是如果您已检出相同的分支,则Git不会更新工作副本.您必须自己做.

    I have a project that is open sourced using git for revision control. Soon, I am going to release a premium hosted version of the project as well, but there will be changes made to the code specifically for the premium hosted version (performance, etc.), that should not exist in the open source version.

    I want to avoid having two separate directories/projects, because if I fix a bug in the open source version, that bug is most likely in the premium hosted version as well. I don't want to make changes in two places.

    What is the best way to manage this? Simply branching in git won't work right, because some files need to have 2 versions: an open source version and a premium hosted version.

    解决方案

    And yet, branching should work, and will allow you to maintain two separate versions.

    If you have a bug which applies to the premium version, fix it on master, and merge it on premium branch.
    Git will only merge what has changed since you branched between master and premium, ie your bug fix.
    On another way to publish an hotfix both in master and premium would be to do it from the common ancestor: see "Git merging hotfix to multiple branches".


    Update 2015: git 2.5 (July 2015) has replaced git-new-workdir presented below by the new command git worktree add <path> [<branch>].

    For more, see "Multiple working directories with Git?".


    Original answer 2012:

    me-and mentions in the comments the command git-new-workdir.
    See:

    One solution to this is to simply create another local clone of your repository. Git automatically uses hard links when you clone locally, so cloning is very fast.
    But there is one problem with this: You now have another, separate repository you need to keep up to date.

    This is where git-new-workdir comes in.
    Instead of doing a full-blown clone of your repository, it simply sets up a new working directory (with its own index) for you.
    The actual repository itself is shared between the original and the new working directory. This means:

    • If you update one repository, the new commits are instantly visible in all other working directories as well.
    • Create a new commit or branch in one of your working directories, they’re instantly available in all working directories.

    Note: Even though the commits are automatically there, Git won’t update the working copy if you’ve got the same branch checked out. You’ll have to do that for yourself.

    这篇关于如何管理一个项目的多个版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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