Git files by default (ignored after the first click)

How would you decide to configure this script in git:

My source has a settings file with configuration settings like db connection credentials etc. (this is the source of Drupal, and I mean settings.php)

When developers clone a source, they will need to log in and change the settings specific to their environment. These changes, of course, should not be thrown back. And at the same time, I want them to be able to work with this default template (since most of it will not be changed).

So .gitignore doesn't work here because I want it in my first clone. Do I need to teach every new developer about git update-index --assume-unchanged ?

Is there no way to do this?

+8
git
source share
3 answers

I would rename database.php to database.php.sample and add database.php to .gitignore .

Whenever a new user appears, simply copy it from database.php.sample to database.php and make the appropriate changes.

+9
source share

A sliding way to do this would be to use a filter filter , with a smudge script :

content driver

Based on the Pedro clause (with database.php in .gitignore ), you would

  • version of a database.php.sample
  • copy it to the private (i.e. not with the version) database.php via smudge script (on git checkout ) only if the specified private database.php does not exist yet.

As with git 1.7.4, %f in the filter definition will be replaced by the current file path; see .gitattributes man page

0
source share

Yes there is. This is the solution that I have already posted.

Use git add -N on database.php , then git add -p . Edit the chunk to replace the secret data with placeholders.

One thing you should be careful about is that you should never git add . from the root of the repository, but nobody does it, right ?;)

0
source share

All Articles