2

Here's the problem: I'm developing a few projects that need to somehow store credentials used for external services - for example, an e-mail address and password. I figured it falls into "configuration" and decided to move the variable data into a separate file the program reads from. I don't want this file to be pushed to upstream though, because in some of my smaller programs, written for personal needs, I test on a production environment and the data are usually quite sensitive.

On the other hand, I don't want a basic .gitignore solution or its equivalent - instead of not uploading the file at all, I'd prefer to send another file in its place, an example configuration file, while keeping the "real" file on its place on my computer. Is there any simple way of achieving it?

If you need more details to answer the question, I'd prefer an answer regarding Git VCS, Python scripts and Linux OS.

d33tah
  • 10,999
  • 13
  • 68
  • 158

2 Answers2

1

One possible solution:

Commit and push a "sample" config file. Then, make the modifications you want to the local config file. It will now be marked as modified in Git.

Use git update-index --assume-unchanged config to permanently ignore future local modifications to the config file (use --no-assume-unchanged to resume tracking modifications).

This way, you will have a sample config in the upstream repo, a customized config in your repo, and you will not accidentally commit the changed config because Git will not mark it as modified.

nneonneo
  • 171,345
  • 36
  • 312
  • 383
  • Note that this is this is only stored locally, so if you're sharing your repository, everybody will have to run the same command. – Sylvain Defresne Jan 27 '13 at 19:29
  • As long as I am the only team member of most my projects so far, I guess could live with that. Thanks! – d33tah Jan 27 '13 at 19:34
0

Another thing you can do is use .gitattributes filters. It lets you specify certain files to pipe through a unix command. You could write a ruby script to scrub out your passwords and replace them with dummy values, or just use sed or awk. You could go a lot crazier than that and use it for some really dangerous things also, heh. See this other answer for some details.

Community
  • 1
  • 1
CommaToast
  • 11,370
  • 7
  • 54
  • 69