Search code examples
gitgithubgitignoregitattributes

Github different versions of the same file: one for development & one for the repo


I'am authoring a PHP CMS, that needs an installation to work.
The installation generate a config file.

At localhost i work on an installed version (with a specific config file),
But the users who download the CMS from github would have an empty config file (= uninstalled version).

What I want :
-a specific config file (config.php) at localhost (to work on)
-an empty config file (config.php) on github (to be downloaded)

I've run across this post : Can git automatically switch between spaces and tabs?
Not sure if it's really what I'm looking for.
voila.


Solution

  • First, it is not recommended to store configuration files in a repository, mainly because of the reason that the configuration only applies to one environment.

    This gist lists some solutions to this problem.

    In your case, I would rename the empty config file to something like config.template.php, that others can copy to config.php and fill in the details. config.php is then added to the .gitignore file.

    That way, the configuration files are only local, and not part of the repository.