Last Updated: February 25, 2016
· filosottile

Switch back and forth from a dev configuration with patch

Between your local dev code and the code you run on the remote (staging or production) server there's always some difference, if anything the database host etc.

My solution is to keep a patch, generated for example with git diff on a "dev state" working directory after a "production state" commit and then enter and exit the dev state with

patch -p1 < dev.patch


patch -p1 -R < dev.patch

Where -R means reverse, that is, it unapplies the patch.

P.S. you can even set is as a git hook.