标签云

微信群

扫码加入我们

WeChat QR Code

Let's say you have a typical web app and with a file configuration.whatever. Every developer working on the project will have one version for their dev boxes, there will be a dev, prod and stage versions. How do you deal with this in source control? Not check in this file at all, check it with different names or do something fancy altogether?


I use this approach, I just have a main.php.tmpl and when I checkout a new copy just copy it to main,php. I add the main.php file to the ignore list to avoid commit it by accident.

2018年08月15日55分39秒

+1 absolutely for stressing that configuration should still be versioned

2018年08月14日55分39秒

And if username is not reliable for whatever reason, then you can have a single file with only one line giving the name of the override config file. This way, there is very little (as in about 10 characters or so) which are not version controlled. And the README file could explain that you need to make that file.

2018年08月14日55分39秒

doesn't account for different env setups though right?

2018年08月15日55分39秒

This works extremely well if there are only a few difference between the environment (ie connection strings)

2018年08月15日55分39秒

and assuming there are not 100s of developers all putting their customized settings there as well (it would still work, but be very cumbersome)

2018年08月14日55分39秒

But when the developers testers push into the mainline, their changes to the template file will be pushed in as well. No?

2018年08月14日55分39秒

Unless there's a solution to Nick's comment, this will not work from what I see. Or maybe explain what flow model you're using which would solve the issue.

2018年08月14日55分39秒

I agree with the template approach with any necessary adjustments baked in at build time. However on the branching topic... What if there were multiple templates (dev, test, etc.) and developers simply omit changes from their commits. Not foolproof but could work with cooperation.

2018年08月14日55分39秒

Noumenon updated the answer to clarify

2018年08月14日55分39秒