Using .gitignore examples

A .gitignore file is a plain text file where each line contains a pattern for files/directories to ignore. Normally, this is placed in the root directory of your repository. This is the recommended way. The patterns in the .gitignore file are relative to the location of the file.

File names

Easiest pattern is a literal file name:

.DS_Store

This will ignore any files named .DS_Store which is common in MacOS.

Directories

You can ignore entire directories by including their paths and putting a / at the end:

node_modules/
logs/
secret_directory/

If you leave the slash ‘ / ‘ at the end you will match both directories and file names.

Leave a comment

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