Host Project on Public GitHub Repo but Hide Sensitive Information

githubversion control

So I'm fine with the source code to my files being public, but I obviously don't want my passwords/login info/etc to be public.

How can I host the repo with GitHub publicly but keep myself safe?

Best Answer

Generally, all config data like passwords and database info will be kept in a config file. To keep private data safe, I usually:

  • Create an example config file that is hosted with the project
  • Provide documentation on modifying the example to be the actual config (rename the file, replace variables, etc.)
  • Add the actual config file to .gitignore so that it is not a tracked file

Those are my thoughts ...