The situation

I have code which has features X and Y.

Bob needs access to the code to help develop feature X further.

Normally I would allow Bob to clone the code, but the problem is that feature Y is confidential, so this is not possible. Bob does not need to be able to view feature Y code to develop feature X further.

If I create a new branch to share with Bob and delete feature Y from the code, it will still be viewable in the commit history.

So I guess the only option is:

  1. Create a new branch and delete feature Y.
  2. Create a completely new repository to share with Bob
  3. Copy the files (while the new Y-less branch is checked out) to the new repository.
  4. Give Bob access to that new repository.
  5. After Bob develops feature X further, cherry pick relevant lines and files, and put them into my master. (painful)


Is there a better way to go about this?

2 Answers 2


A no less effort but more permanent fix would be to split feature X and Y each into their own repositories. Then the master would just reference the other repositories as libraries (best practice for this is to use submodules).

This way you do not need to manually add the new development to feature X as you are using it straight from its own repository.

  • Thanks, this is a nice way of doing it. It doesn't get around the initial work involved, but it's worth it in the long-run.
    – Gerhard
    Jan 6, 2014 at 5:30

As Tristan said, splitting the features into their own repositories is the best practice, if possible. However, there are alternatives if the code is too intertwined.

One is to use MOE, which is a program that basically automates translating a repository between an open source and a closed source version.

Another option is to create a Bob branch, then copy out the parts you want to send to him. When he sends you changes, just check out that branch and copy all his files back in. Then it's a simple merge back into your main branch. I've used this method when the changes were in a different VCS.

  • Thanks for the input. I didn't need to go as far as MOE, but separate branching was another viable option.
    – Gerhard
    Jan 6, 2014 at 5:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.