问题描述
你会如何在git中设置这个场景:
How would you go about setting up this scenario in git:
我的源代码有一个设置文件,包含配置设置,比如db连接凭证等...(这是一个Drupal源,我指的是settings.php)
My source has a settings file with configuration settings such as db connection credentials, etc... (this is a Drupal source and I'm referring to settings.php)
当开发人员克隆源代码时,他们需要进入并更改特定于其环境的设置。这些变化当然不应该推回原点。同时,我希望他们能够使用此默认模板(因为大部分内容不会被更改)。
When developers clone the source, they'll need to go in and change settings specific to their environment. These changes of course should not be pushed back to origin. And at the same time I want them to be able to work with this default template (since most of it will not be changed).
所以.gitignore不起作用这里是因为我想要它在他们的第一个克隆。
是否需要向每位新开发人员讲解 git update-index --assume-unchanged
?
So .gitignore doesn't work here because I want it in their first clone.Do I need to teach every new developer about git update-index --assume-unchanged
?
是不是有一个很好的方法来做到这一点?
Isn't there a slicker way to do this?
推荐答案
我会重命名 database.php
到 database.php.sample
并添加 database.php
到 .gitignore
。
I would rename database.php
to database.php.sample
and add database.php
to .gitignore
.
只要有新用户出现,只需从 database.php.sample
到 database.php
并进行相应的更改。
Whenever a new user comes up, just copy from database.php.sample
to database.php
and make the appropriate changes.
这篇关于Git的默认文件(第一次拉后忽略)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!