2009-09-29 32 views
9

git似乎没有做我想在这里,所以我需要一些建议。我有一个包含密码等敏感信息的配置文件。说我在空白/通用值的配置文件已检查:防止使用git密码文件的意外登记

username = 
password = 

现在我用实际值填充它,然后添加文件的.gitignore(文件名是build.properties)

username = bob 
password = secretpassword 

即使我已经将它添加到.gitignore,git仍似乎“看到它”。我应该在这里做什么?

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") 

我误解的东西吗?

+0

所以只是为了澄清,似乎如果有人做'git -a -m'whatever''它会自动检查密码仍然是? – corydoras

+0

是的,如果它在版本控制下,它将包含在提交 – knittl

回答

21

.gitignore只会忽略尚未签入的文件。在您的情况下,您需要创建password.file.template并检入,然后将您的password.file放在.gitignore文件中。

4

那么它说修改:build.properties,所以有人已经签入此文件。我最好的猜测是:删除文件,提交更改,然后重新创建它,而无需签入。

+0

是的,正如我在问题中所述,我检查了一个通用版本的配置文件作为模板,所以很清楚用户必须输入什么构建文件。 – corydoras

+2

好的,当你想分发模板时,你无法将它添加到.gitignore文件中(因为git不会这样)。那么为什么不创建一个build.properties.template文件并检查?然后,您可以指示其他开发人员删除该文件的.template部分并填写其凭据。 – seb

+1

这也是我如何使用SVN完成的。创建一个模板文件,即。 config.sample.txt,然后将实际的配置文件作为忽略的文件放置,以免意外提交。 –