2

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?

8

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 ...

0

You have at least two ways:

  • Don't use Git, here such obvious task is problem, and move to Mercurial with MQ, in which you store in public place any scrap, replaced in local workplace by actual data (local MQ-patches)
  • Read about smudge/clean filters and store in repository template-snippets, expanded automagicaly to real data in Working Directory
  • 3
    If the question implies using git, the not using git isn't an answer. – Steve Robbins Dec 12 '12 at 17:48
  • @SteveRobbins - I wrote "You have at least two ways...", BTW. Templating and handwork is old style, filters - Git-way, JFYI – Lazy Badger Dec 12 '12 at 19:22
0

I like to configure all my apps from the environment. This allows for a clean separation of code and environment - see The 12-Factor App.

In a Rails project, for example, I'll check in the secrets.yml file with these contents (as an example):

development: secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> domain_name: <%= ENV["DOMAIN_NAME"] %>

Then all of the configuration happens in my environment. There's also a handy gem for Rails that will load a .env file with variables for my environment called dot-env. This file is never checked in (but a .env.example file is provided with placeholder values).

When the app is deployed the tools will make sure to configure the environment before deploying the code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.