Can I make parts of my private repository public?

I have my website as a private repository. I want to make parts of it public, but still keep most of it private. It’s a huge pain to keep the inner ones up to date with my main repository.

Currently i just have multiple repositories nested under my main one, listed separately on github. Is there a way I could choose certain files / folders to make public / private, or maybe give certain users permission to view those folders?

No, you cannot have different public/private settings within one repository.

The closest thing I can think of would be to keep the repositories separate and use submodules to create a unified directory tree, but I can’t judge if that makes sense for your workflow.

I would love to see this elevated to a request: my use case is that, as a professor delivering online content to students and teachers, folder-level privacy would greatly facilitate my ability to put an entire course together (e.g. labs along with lab solutions) and make it available to students, without also giving away the answers to labs. Is there an appropriate place to make this a feature request?

I’m afraid that is fundamentally incompatible with the way git works. If someone can clone your repository, they get all data within it.

So even if Github was to implement such a thing in the web interface your students would just need to clone the repository to get the answers. Which is why I doubt Github would even try. :wink:

A possible solution would be to keep your answers in a private repository, and (automatically) create a public one from that which only contains the question part.

2 Likes

Thanks for the suggestion. I realize this wasn’t really in keeping with a true “Git” workflow, but it so many people use Github in different ways I thought it was worth asking. I didn’t thinking about creating a duplicate without the solutions: total face-palm on my part. That’s a great work-around so thanks for bringing it up!

1 Like