Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I use .gitignore, or auto-detect configurations for different servers in staging?

I am working in a firm where we currently do not have any staging workflow, and things are getting tight. I am trying to set up a proper workflow and have read some excellent tutorials and resources for different approaches. The workflow that I will be using is that developers commit and push their codes to a dev repo, which is then copied to prod repo. Then a simple pull is done on the prod server.

We are using CakePHP. There are 2 servers (prod and dev) and of course the localhost. However, the configurations (db, payments, auth etc) are different for each environment. My main question is that which option is better from the below (other suggestions are also welcomed)?

OPTION 1:

  • Set up all 3 environments with their appropriate configs
  • Use the .gitignore to ignore configs and env-specific files
  • Use simple push/pull

OPTION 2:

  • Use PHP mechanisms to detect the environment and select appropriate configuration
  • No need to use .gitignore (other than may be just ignoring the tmp files etc)
  • Use simple push/pull

I would like to know whats the best way to do this. Also, a recommendation for a Git workflow with easy deployment would be great.

like image 697
Musab Masood Avatar asked Oct 17 '12 17:10

Musab Masood


1 Answers

This is exactly the kind of thing your .gitignore file is for, go with option 1.

like image 162
Collin Avatar answered Nov 15 '22 04:11

Collin