I have a config.php
which suppose to be different in content in different branches, e.g. testing
and master
.
I have asked in another question (Prevent merging a file from master with Git) that how to prevent this file from merging.
But I am wondering, is this the correct way to do so?
I believe this is quite a common use case to have different config files in different environments and you want the config to keep tracked, right?
In the event that you require a merge commit during a fast forward merge for record keeping purposes you can execute git merge with the --no-ff option. git merge --no-ff <branch> This command merges the specified branch into the current branch, but always generates a merge commit (even if it was a fast-forward merge).
For a config file, one solution is to not version it (that way, no merge issue!)
You would use a content filter driver:
You would version:
master
environment)dev
environment)@PORT_NUMBER@
)smudge
' script able, based on the current branch, and based on the content of the checked out file (here the template file) to generate the actual config file (which remains 'private', ie not-versioned).clean
' script able to detect any value changes in the private config file, and store those changed values back in the (versioned) value files.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With