Picture this common scenario: i compromised together a awesome project i wish to tell the planet. So: i use it Github, and fetch it from Github by myself website so people can easily see a demo. This makes upgrading easy: just push from my local box to Github, fetch on my small server.

Let me track site visitors and so i add Google Statistics and perhaps another site-specific stuff (just like a global header for those pages on my small site) towards the project. However, everyone who inspections out my project from Github will get everything stuff too.

You will find a couple of methods to prevent that. I possibly could create a specific 'deployment branch' for my website, but that is cumbersome. I possibly could have type of switch during my code (if ip === myip showStats()), but that is ugly.

An alternative choice may be to make use of githooks, however i don't have any knowledge about that.

Every other suggestions? Are people even bothered when getting deployment-specific code like this within their checkouts?

Much like Breun's suggestion, (so that your question is going to be double clarified) I deploy my Python projects having a configurations.py file which defines the configurations that are required around the production machine. (debug=False, proper database configurations and file pathways...)

In the finish from the file, I attempt to import developmentsettings.py such as this:


    from projectnaam import developmentsettings



The file doesn't appear in version control, which means this will fail and quietly spread the server. On my small dev machine, I by hand produce the file and override specific configurations to complement my dev needs. (such things as sqlite rather than postgres)

This is often extended into a more elaborate deployment strategy, including things like Fabric, Buildout, Capistrano and Chef. All of this will get more essential when employed in (distributed) teams.

My current development flow now goes like: edit code, $ git commit -m "comment", $ git push, $ great deploy master production (<- this pulls 'master' from origin to the server)

Produce a configuration apply for deployment-specific configurations. You can for example possess a conf/defaults.conf for just about any default configurations and let customers put any nearby deployment-specific overrides in conf/local.conf.

And add your configurations.php file towards the .gitignore, or else you might upload it.

Discussing your Google statistics (api)code using the world is not advisable since your stats will be messed up of somebody uses your code without altering it.