filtered version of git repository

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.

  • How to move git commits from master to a different existing branch
  • why does git cherry-pick create a different checksum?
  • How to properly configure ssh keys to multiple remote accounts involving github and bitbucket?
  • how to configure a migrated git repository in gitolite
  • Unable to determine upstream SVN information from HEAD history
  • git add Signed-off-by line using format.signoff not working
  • 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?

  • GAE: Trouble with push to deploy
  • git pull gives error: 401 Authorization Required while accessing
  • How to Check if A Git Clone Has Been Done Already with JGit
  • Git: getting changes from another branch
  • MyBatis Migrations - how to apply missing migration
  • git-http-backend returns error 502
  • One Solution collect form web for “filtered version of git repository”

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

    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 Baby is a git and github fan, let's start git clone.