Reputation: 495
this is a very general question about git - think of a server application for the example below.
The context: Suppose you have a few branches in your repo, among which 'staging' and 'deploy'. To develop the application, you use a private machine with a specific development configuration file. Your app is about to be deployed on a public machine. However the public machine requires a different configuration file (e.g. it has to access a specific database or so).
The problem: If I commit my config file in 'staging', do some changes, and then merge into 'deploy', it will overwrite my deployment config file, and this would be incorrect. If I don't track my configuration files, I could lose them at any point.
The question: How can I protect both files in both branches, so that neither is lost at any point? How can I assign these files to the branches they are owned by? Is there a way to do this all transparently, so that I can just use git's usual mechanisms without having to think about these files?
Thanks!
Upvotes: 2
Views: 405
Reputation: 54507
Branches are not the right way for this in my experience. Try to separate development and deployment into separate repositories. Your application repo should not contain the configuration files used for a production deployment. A default configuration that can be used for a local deployment is usually fine to have.
Anything else should be kept outside of the source code repo for the following reasons:
If you still want to keep track of configurations (which is a good idea in general), either
file-uat.config
, file-production.config
) - you could also use directories in the same repo, so one directory holding all of the uat files, one all of the production files, etc. Ormyapp-config-uat
, myapp-config-production
. Either of these approaches should work well with a scripting solution that will automate cloning/updating the configuration files into the environments in question.
Upvotes: 3