Ignore Files with .gitignore

Git Tips & Commands

There will be some files that you don't want Git to track. You can use a .gitignore file to list the files and/or folders that Git should ignore.

Create a Git Ignore File

1. Using your code editor, save an empty file named .gitignore into the based (root) folder of your Git repo.

NOTE: On Unix-based operating systems such as macOS, files that start with a period (.) are hidden, so you will not see the .gitignore file in the macOS Finder unless you show hidden files. You should be able to see it in most code editors.

2. In this file you list any files you want to ignore. Here's an example of some files everyone would probably want to ignore:

# Mac
.DS_Store
.DocumentRevisions-V100
.Spotlight-V100
.Trashes

# Windows
Thumbs.db

Syntax for .gitignore

To learn about the syntax for this file, refer to:

Go Beyond Git

We offer the best coding courses and bootcamps for students at all levels of experience. Classes are hands-on and students receive workbooks with step-by-step instructions through exercises with real-world applications. Check out our programming courses now:

How to Learn Git

Master Git with hands-on training. Git is a free, open-source version control system that allows developers to track the changes they make to code.

Yelp Facebook LinkedIn YouTube Twitter Instagram