就像SO上这个问题描述的场景: http://stackoverflow.com/questions/928646/how-do-i-tell-git-to-always-select-my-local-version-for-conflicted-merges-on-a-sp
有两个分支,每个分支使用不同的配置,例如:
config.txt (on release branch):
database = 10.9.8.7
config.txt (on develop branch):
database = 192.168.0.1
当需要把develop分支的功能合并到release分支时,不希望config文件被合并;
有以下几种解决方案:
不知道大家有没什么建议?
参考: http://stackoverflow.com/questions/928646/how-do-i-tell-git-to-always-select-my-local-version-for-conflicted-merges-on-a-sp
http://stackoverflow.com/questions/2250040/using-github-to-host-public-git-repositories-whilst-ensuring-that-sensitive-data#
http://blog.miniasp.com/post/2014/12/23/Git-Advanced-Assume-Unchanged-Skip-worktree.aspx
It is easier to maintain configuration files for different environments if they are placed in different files
Make environment judgment in the code (common methods include IP, hostname, environment variables, etc.) and read different configurations respectively
A further solution is to have a configuration center responsible for issuing configurations, and a garrison elf responsible for finding the configuration center to pull configurations, cache configurations, and cooperate with the center to update configurations, etc.
In short, I personally feel that maintaining the configurations of different environments through different branches will get half the result with half the effort... If you add a test environment, a pre-release environment, and maybe even a unit test environment, a sandbox environment, etc., if you still use branches for more than 3 different configurations If you maintain it, it will basically collapse... If you must do it, I recommend imitating it
phpunit.xml.dist
的形式,gitignore掉config.txt
,然后维护正式的config.txt.dist
,代码里优先读config.txt
,然后读config.txt.dist