过滤版本的git存储库 [英] filtered version of git repository

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

问题描述

我有一个问题,我们需要为外包商提供我们的git存储库的过滤版本。

因此,我们需要维护一个版本的git存储库,有一些关键字找到并替换为别的东西。



这背后的原因是我们不希望外包商在代码中粘贴代码,发生在过去。



如果git可以暴露这种类似的东西,这将很酷,但我想这是不可能的,因为它会改变所有SHA ids。



我想解决方案是有两个独立的git仓库,它们以某种方式保持同步。同步将需要2路。因此,当我们对代码库进行更改时,这些更改会被推送到过滤的代码库(并在过程中进行过滤),如果外包商进行更改,那么这些更改会被推送到我们的存储库,但不会在返回时过滤。 / p>

我们或许可以用挑选樱桃等东西来扯一些东西,但是我想可能会让它变得可靠。我想在概念上它与git-svn很相似。



有没有可以产生这种结果的工具?

解决方案

正如欧文在评论中提到的那样,正如我在他引用的答案,这是一份 过滤器驱动程序





就你而言,你会:


  • 有一个特殊的分支,其中一个git属性声明一个outsourcerscript

  • outsourcerscript能够替换这些关键字
  • 合并您的工作,然后检出该分支以获得过滤的工作树

  • add t他将工作树的内容添加到您需要与外包商沟通的独立回购库中。 他们到一个导入分支,其中 clean 脚本将在提交时恢复正确的关键字。

    然后您将该导入分支合并到通常的工作中分行。


    I have a problem where we need to provide a filtered version of our git repository to an outsourcer.

    So we need to maintain a version of our git repository that has certain keywords find and replaced with something else.

    The reasoning behind this is we don't want the outsourcers pasting code in forums that has our clients name in it as it has happened in the past.

    It would be cool if git could expose something like this on the fly, but I imagine that isn't possible because it would change all the SHA ids.

    I guess the solution is to have 2 separate git repositories that are kept in sync somehow. The syncing would need to be 2 way. So that when we make changes to the code base, those changes get pushed to filtered code base (and filtered on the way) and if the the outsourcers make changes then those changes get pushed to our repository, but unfiltered on the way back.

    We could probably rangle something together with cherry-picking, etc. But I imagine it'd be a bit of work to get it reliable. I suppose conceptually it's similar to git-svn.

    Are there tools out there that could produce this outcome?

    解决方案

    As Owen mentions in the comments, and as I illustrated in the answer he references, this is a job for a filter driver.

    In your case, you would:

    • have a special branch where a git attribute declares a outsourcerscript
    • maintain in that branch a outsourcerscript able to replace those keywords
    • merge your work, and then checkout that branch in order to get a filtered working tree
    • add the content of that working tree to your separate repo you need to communicate to the outsourcer.

    For changes coming from the outsourcer, you add them to an import branch where a clean script will, on commit, restore the right keywords.
    And then you merge that import branch to your usual working branch.

    这篇关于过滤版本的git存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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