Git commit configuration at initial commit, but never again?

I started using git for my projects, when I create a project, it has a configuration folder containing configuration files:

application/config/config.php application/config/database.php application/config/routes.php 

When I first commit, I want these files (with their default values) to be committed, so they exist in the repository as "standard" configurations, and if I clone to the repository, I get these files. When I update them to contain my configuration variables (for the version I'm developing), I do not want them to be updated in the repository, I want them to remain in the default state in the repository.

I tried first to execute them in my default state, and then add them to my .gitignore file, for example:

 application/config/* 

Now, when I commit my configuration files, they are not executed (yay!), However the initial default values ​​disappear, the application of the / config / folder no longer exists in my repository.

I assume that something obvious is missing here, but I'm very inexperienced with git.

How can I commit configuration files in my first commit, but never again, remaining in the repository in their default state?

+4
source share
1 answer

You can, after the version, update your index:

  git update-index --assume-unchanged application/config/config.php 

Or you can even update the index for real:

  git update-index --skip-worktree application/config/config.php 

(as shown in the git update-index --assume-unchanged and git reset "section)


Another solution is not to release the final configuration file (as their contents may change as you indicated), but to use a filter :

filter driver

You would run the following versions:

  • template files ( application/config/config.tpl )
  • configuration value files (default and others for different environments)
  • a script is able to recognize the contents of the configuration file (since it will not have its own path ) and generate the final configuration files in accordance with the current environment.
+7
source

Source: https://habr.com/ru/post/1397244/


All Articles