XQEWR
XQEWR

Reputation: 638

How to hide personal info from a publicly shared GitHub?

I share my Java project on GitHub (because I believe in open-source code and no hidden tricks). Anyways, I have a unique UserAgent I got from a website for API usages... I want to know how I can hide that from GitHub without making my project private... What can I do? I tried searching Google, but no one seems to have the same problem. I can't use a separate file and then add it to .gitignore because it won't work when I deploy the project. Please help!

Upvotes: 4

Views: 2013

Answers (3)

forvaidya
forvaidya

Reputation: 3315

Just encrypt confidential info using GPG and also sign your tags.

Upvotes: 0

VonC
VonC

Reputation: 1323653

I want to know how I can hide that from GitHub without making my project private

You cannot push that information to the repo then.

What you can do is declaring a content filter driver which, on checkout, will check if it has access to a private source of information (elsewhere than your public repo, potentially elsewhere than GitHub), and generate the right file (which remains private, and is declared in the .gitignore).

https://i.sstatic.net/3wuqy.png

That content filter driver is declared in a .gitattributes, and is taking a template file (which is versioned but contains, by its nature, no value), and will generate the complete file with:

  • default values (if the source of the private data isn't found)
  • sensitive values (if the script has access to the private source of information)

Upvotes: 2

gturri
gturri

Reputation: 14599

As suggested in comments: put this information in a config file.

Here is an example: this javascript project provides a config.js.template file, but the application expects a config.js file (which is gitignored). If this file doesn't exist, the template is copied. That way, it will run with sensible default values even if the user doesn't take the time to write his own config first.

Moreover, since you're saying yo plan to "switch" to a config file, I guess those personal config values are currently in your code. So don't forget to also clean your old commits before pushing to github!

Upvotes: 1

Related Questions