Git Quick Tip – Ignoring a file

Sometimes in a coding project there will be files or directories that should not be included in a git repository. Common examples are temporary folders, log files, or files containing passwords/keys that should be regenerated by each installation of the software and kept secret. Fortunately, it is very easy to ignore these files when committing the git project.

In your project directory, you will find the file .gitignore. In this file, simply create a list of the project files and directories that should not be included. The list is relative to the current directory, so you do not need to include the full path to the files. You can even ignore based on simple wildcards. For example:

dan@rails-dev:project $ cat .gitignore
.bundle
db/*.sqlite3
log/*.log
.DS_Store
secret_token

Leave a Reply

Your email address will not be published. Required fields are marked *