Add .gitignore file to ignore backups and error-log

I'm always dealing with untracked files from the database and error-log, which you don't want to commit, so I decided to add a .gitignore file to ignore them. I would like to find a way to be able to ignore lib/config.php. Maybe make a lib/config.php.sample and then ignore lib/config.php? But there would need to be a way to generate the config.php file automatically from the sample.