Many of my projects have files that contain usernames/passwords for various services (e.g. MySQL). For a public project on Github, this is unacceptable. Here is a solution:
- Make a duplicate of the file named <filename>_sample and remove the sensitive data from it.
- Add a line to your .gitignore file to untrack/ignore the file.
- If the file was previously tracked you must untrack it with
git rm --cached <filename>
The sensitive file will not be added to your future commits.