开发者

filtered version of git repository

开发者 https://www.devze.com 2023-04-01 04:44 出处:网络
I 开发者_JAVA技巧have a problem where we need to provide a filtered version of our git repository to an outsourcer.

I 开发者_JAVA技巧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.

filtered version of git repository

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消