I'm checking out the new configuration management module for Drupal 7. It's effectively a back-port of the new configuration management that's in D8, and looks like it's going to be a great alternative to the use of Features for storing configuration.


I have a test github repository where I'm playing with the module. I'd like to put my code and configuration in this repo, and I'd quite like to keep the default location for the config files (sites/default/files/config).

I realise that this is more a question about .gitignore files than Drupal. However, how can I change my .gitignore file so that I can add the config files to my repo?

The current gitignore is here. (This is the excellent .gitignore file provided by github as a default for Drupal projects).

The simple change of adding !sites/default/files/config/* to the end of the file doesn't seem to help.

EDIT: I also tried this, with no luck:


I'd be grateful for any tips on how others manage to solve this problem. Thanks!


You can do that if you ignore the content in "sites//files/" directory and not the directory itself "sites/*/files/", I think this is not the best way to do it but that is what I have managed to find.

Ignore all the content in "sites//files/" except for the config directory

# Ignore paths that contain user-generated content.

or you can only ignore the config/*.inc

# Ignore paths that contain user-generated content.

remember to replace the default "sites//files" with "sites//files/*" in the .gitigonre file.

Another way is to forcefully add the files you want to commit, this will add the files in the directory and track there changes, but will not detect new files added in the future.

git add -f default/files/config/

git doesn't ignore what has been tracked before. You can do git rm --cached <file>. Note that any repo which pulls this change will delete their local copy of that file. You can "bring it back" using git checkout HEAD@{1} file immediately after pulling / merging.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.