2

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?

IMTheNachoMan
  • 5,343
  • 5
  • 40
  • 89
  • Separate private repository, with your build system / application having access to both? What do you mean precisely by "use them"? How do you intend the public to use the files that they cannot read? – Charlie Dec 14 '21 at 03:08
  • Are you familiar with Google Apps Script and `clasp`? `clasp` is kinda like `git` but for GAS. So in each repo folder I have my code, `git` files, and `clasp` files. `clasp` files have some sensitive information in it. I want other contributors to use the same `clasp` files but if someone in the public clones my repo they wouldn't need my `clasp` files. – IMTheNachoMan Dec 14 '21 at 13:52

1 Answers1

2

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.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • This is great. Thank you. The `content filter driver` link keeps linking to other links and eventually a 404 but I can google it to find it. Thanks! – IMTheNachoMan Dec 14 '21 at 13:51
  • @IMTheNachoMan Could you tell me which link lead to a 404? I will fix it. – VonC Dec 14 '21 at 22:21
  • Heh. Your [content filter driver](https://stackoverflow.com/a/69476874/6309) leads to [`.gitattributes` declaration](https://stackoverflow.com/questions/2316677/can-git-automatically-switch-between-spaces-and-tabs/2316728#2316728) leads to [git attribute filter driver](https://schacon.github.com/git/gitattributes.html) which is a 404. – IMTheNachoMan Dec 15 '21 at 23:12