.gitignore - 项目里有个config.php文件,我希望它加入版本库.但是git pull and git push的时候不更新这个文件
大家讲道理
大家讲道理 2017-05-16 12:02:52
0
4
557

RT

简单介绍一下模式

代码放在github

然后本地clone下来,修改后git pushgithub

然后线上服务器git pull

因为线上和本地的配置不一样,每次更新,config.php都得改一次.

如果把config.php文件放到.gitignore里面

别人想要clone的时候,会没有这个config.php,项目就运行不了

请问有没有什么好的解决办法

大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

reply all(4)
巴扎黑
  1. Thisconfig.php肯定是要存放于git上面的,至于git上的这个config.php应该是默认配置,每个客户端的config.php里面的配置可能或多或少不一样,那需要每个客户端自己改,所以说默认的config.php只应该有一个,只有需要修改默认配置的时候才需要提交config.php的改动,否则不要git add

  2. So I give you a suggestion, write a deployment script, the first stepclone,然后第二步就通过sed等做一些文件操作,比如修改config.php配置信息啦,本地开启debugla, etc. It is best to complete the local environment through the script with one click

巴扎黑

You can rename config.php to config.php.example and add it to version control. When you need clone later, you only need to manually rename config.php.example to config.php, like this It can be personalized and let others know your configuration attributes.

为情所困
git update-index --assume-unchanged [path]

Refer to stackoverflow

淡淡烟草味

I usually have two configs, one online and one for testing. The online config is imported by default and the entry file is manually modified locally. The entry file is neither submitted nor updated

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!