Best solution to make only part of our repo public?


I hope you can help?

How can I contact the people who have stared or watched our repo?

Also, we want to now hide part of our code but keep some of it public along with the, is this possible?

As far as we can tell, there are 2 solutions to us:

  1. We create a new private repo and move the code there we wish to make private. But if we do that then how do we then remove and hide that code on our existing public repo? Even if we delete the code and check-in then it will still be visible in the history? Also, if we move the code to the private repo would the full history also be copied across?

  2. We create a new public repo and move the code we want to keep public to it. Does the history copy across too? We then make the existing public repo private. Can we then setup a re-direct so when people try to access the old public repo we have now made private, they are instead re-directed to the new public repo.

Which of these options do you support?

Or is there a 3rd better option?

Also, it would be great to have the code we wish to remain public to be linked to the private repo because it is a project that is used in the private code and we do not wish to have to maintain two copies of the same project/code. I know you can have linked repos but not sure how to set that up?

Any help would be really appreciated.

Many thanks,

You can check to see if they have a public email address listed on their profiles and contact them that way. Or, you can contact the watchers by opening an issue. All watchers will get a notification for any new issue on your repository.

Yes and no. You are correct that you will have to create a new repository one way or the other. Here’s what I would, most likely, do:

  1. Rename the current repository from whatever to whatever-private
    • At this point, you don’t have to worry about the history because it’s all still there along with the issues, PRs, etc
  2. Make whatever-private private
  3. Create a new repository named whatever
  4. Use a technique (possibly like this one) to move only the parts of the repository code you want to be public into the new public repo
    • These techniques maintain the history for the part of the repository you move
    • The drawback here is that you can only move code to the new repository, not issues, PRs, or other artifacts

It depends on what you mean by “linked”. If you mean that you can push code from the private repository to the public one via some mechanism, that is one of the magical things about git. If you know what you’re doing, you can move code from any git repository to any other git repository. But it isn’t going to protect you from making things public again accidentally, so you’ll have to be very careful about that and probably set up some automated scripts to ensure that mistakes are less frequent.

I hope that helps! Let us know if you have more questions.