开发者

'Desynchronize' a PHP config file with Git

I'm currently working on a PHP site, and am using Git both locally (development) and on the production site (a repo on my web server uses a post-recieve hook to deploy to the web root), the details of which are outlined at toroid.org's 'Using Git to manage a web site' article.

Issue is that I also have a config.php file (of sorts) that I use for connecting to the database that differs between my local development environment (a local install of MySQL with test data) and my remote 'production' web server (which has it's own 'live' database). Whenever I push my changes to the website however the config file goes with it and replaces my 'live' config with settings connecting to the (nonexistent) development one! I then have to manually SSH to my web server and replace the config.php file, kind of defeating the purpose!

Is there any way I can get Git to... kind of 'desynchronize' the config.php file? The 'development' config.php should never get saved to the git repo, and when the production server deploys the PHP scripts etc to the web root directory, it should also leave the existing 'production' config.php file untouched.

Is there any way of doing this w开发者_运维知识库ith Git? Thanks a million for your suggestions!

TC


First I would remove config.php from the repository, then I would create a file named ".gitignore" and add the filename "config.php" to it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜