Can I make parts of my private repository public? #22382
-
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? |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 1 reply
-
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. |
Beta Was this translation helpful? Give feedback.
-
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? |
Beta Was this translation helpful? Give feedback.
-
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. 😉 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. |
Beta Was this translation helpful? Give feedback.
-
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! |
Beta Was this translation helpful? Give feedback.
-
You can use a trick. You can automatically create a public part of your private repository. For example: you can use gitexporter command.
Run command Folder Then you can push Like so:
|
Beta Was this translation helpful? Give feedback.
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.