This is a fairly common question, and there isn't a One True Answer.
These are the most common techniques.
- Modify your app such that, before loading its config from e.g.
config.ini, it first looks for e.g.config.mine.ini. Track a standardconfig.iniin your repo, but if you need to override the values in it, copy it toconfig.mine.iniand modify. Then configure git to ignoreconfig.mine.php. - Have your app just look for e.g.
config.ini, but don't track this file. Instead create and track e.g.config.sample.ini. Everyone who clones the repo has to copyconfig.sample.initoconfig.ini, but they can modifyconfig.inias much as they want. - Have your app look at environmental variables for its config, before using the values from its config file. Then set your your shell to load those environmental variables on login. Only works if your app doesn't need much config.
- Use some gitattributes clean/smudge magic as suggested by SethRobertson, see the other file in this gist.