What is the best way to handle configuration files with git?

Say my application has a configuration files in plain-text. They contain some sensitive information which is required to test the application in my dev environment. I use different OSes to access and work on my projects (win, mac, … ).

I do not wish some of the information in the configuration files to make it to my public git repository. In best case I want the sensitive information to be replaced with placeholders and have the configuration files uploaded to the repository to keep track of their structure.

  • Where is the Git Repository Path created?
  • C++ project source code layout
  • Measuring “closeness” in large source trees
  • Restructuring Files in Git Repository
  • Git repository structure and modularity
  • convert current git repo to one compatible with git-buildpackage

  • How would you approach the problem?

    The hook itself wouldn’t be much of a problem for me to write. I’m more interested how to tie it all together, possible directory structure, etc. I’m quite new to git.

  • Jenkins Git integration - How to disable SSL certificate validation
  • Gitlab is not showing commits after pushing
  • how to reduce server git repo size when delete a branch
  • Eclipse forget my Git password and username everytime after I do a push
  • How do I disable being able to set the git commit message from the command line?
  • which way to git merge?
  • One Solution collect form web for “What is the best way to handle configuration files with git?”

    There’s a convention followed in the Django world that you could use – there is a standard settings.py file that imports a local_settings module at the end if there is one available.

    Have all your secret stuff in that local_settings.py file and add it to .gitignore so that it doesn’t go to the repository. This way, people will know that they can add their own settings to local_settings.

    For example,


    DATABASE_USERNAME = 'your username here'
    DATABASE_PASSWORD = 'your password here'


    DATABASE_USERNAME = 'my top secret username'
    DATABASE_PASSWORD = 'my top secret password'

    The best part is that whatever you’ve defined in settings.py will get overridden by the same name in local_settings.py.

    Git Baby is a git and github fan, let's start git clone.