I'm using Git for both my development and live websites, and keep each in their own branches 'dev' and 'master'. When I finish testing on the 'dev' branch I merge my changes back to 'master', however there are several files which I need to keep specific to just the 'dev' branch / server.
I.e. index.php have a 'development server' message shown at top of all pages, and no Google Analytics tracking, and I want to keep it this way.
Also some config files which should not change when I merge.
I have been using cherry-pick, but this is slow and frustrating... is a better way to do this?
You want to setup .gitignore files in your repo.
Basically your config files should not be added to your repo. You can use a .gitignore
file
to do this.
Say if you have an includes/
directory. In there make a .gitignore
file with the following in it:
config.php
This says that config.php
from this directory should not be added to the repo. Note: this will not work if the file has already been added. If it has already been added then you must git rm the file.
Now since the config.php
file won't exist in your repo at all, I would recommend creating a config.sample.php
which looks exactly like you config.php
file and is part of your repo. This way when you clone (or someone else clones) your project they know exactly what should be in the config file.