Home > Net >  How to prevent non contributors from seeing specific files in a public GitHub repo?
How to prevent non contributors from seeing specific files in a public GitHub repo?

Time:12-15

I have a public GitHub repo with a bunch of files. For certain files, I want them to be in GitHub so I, and other contributors can use them, but I don't want everyone (the public) to be able to see them.

Is this possible?

CodePudding user response:

Git or GitHub cannot protect part of a public repository: if you can access said repository, you would clone everything.

That being said, you could add a content filter driver which would automatically on checkout:

  • fetch those files from another source (separate private repository, as commented)
  • create them in your local working tree (if your local public repository clone)
  • make sure they are ignored locally.

However, any evolution of those files should be synchronized in a local clone of your separate private repository, and pushed from said local private clone.

  • Related