will
will

Reputation: 1511

Protecting sensitive information in Git

Assume I have a project I'm working on that is a blog. In this blog I have a config file with sensitive information in it. When I decide to push this project to Github, I want the config file filled with example data instead of my sensitive data. What is the best, and most widely used, method of achieving this?

Upvotes: 3

Views: 603

Answers (2)

Jakob Kroeker
Jakob Kroeker

Reputation: 333

One possible approach is:

  1. fill the config file with dummy data, commit changes and push to GitHub
  2. configure git to ignore changes in tracked file:

    git update-index --assume-unchanged config-file

  3. fill the config file with sensitive information

Upvotes: 3

hobbs
hobbs

Reputation: 239781

Don't put it there in the first place. Check in an example config file with a different name, add the real config file's name to .gitignore, and never check it in.

If you've already done commits with your config file in place, use git filter-branch to make it go away before you push anywhere public.

Upvotes: 6

Related Questions