tags:

views:

126

answers:

2

git does not seem to do what I want here so I need some advise. I have a configuration file with sensitive information such as passwords. Say I have checked in the config file with blank/generic values:

username =
password =

Now I fill it with real values, and then add the file to .gitignore (the filename is build.properties)

username = bob
password = secretpassword

Even though I have added it to .gitignore, git still seems to "see it". What should I do here?

hostname$ more .gitignore 
build
ant.build
*.swp
build.properties

hostname$ git status
# On branch dev
# Changed but not updated:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#   modified:   build.properties
#
no changes added to commit (use "git add" and/or "git commit -a")

Am I misunderstanding something?

+2  A: 

Well it says modified: build.properties, so someone has checked-in this file already. Best guess of mine would be: delete the file, commit the changes and then re-create it without checking-in.

seb
Yes as I stated in the question, I have checked in a generic version of the config file as a template, so it is clear what the user must enter in the build file.
corydoras
OK, when you want to distribute the template then you can't add this to the .gitignore file anyway (since git won't pick it up that way). So why not create a build.properties.template file and check that in? You can then instruct other developers to remove the .template part of that file and fill-in their credentials
seb
This is how I do it with SVN too. Create a template file as ie. config.sample.txt, then place the actual config file as an ignored file so that it can't be commited accidentally.
Matthew Scharley
+8  A: 

.gitignore will only ignore files not already checked in. in your case you need to create an password.file.template and check that in. then put your password.file in the .gitignore file.

knittl