What is a .gitignore file?

There are often files that you don't want Git to track or push to GitHub (like .DS_store, which is a system file automatically generated on Macs). Therefore, you'll want to list these files in a .gitignore file!

First, ensure there is not already a .gitignore file in your repository. These are hidden files, so to check for it, you can run $ls -a while in your repository.

Do you see a .gitignore file listed? If so...

  • to open the file on a Mac, run open .gitignore
  • on a PC, the “open” command won’t work, so you can run start .gitignore (which will open the file in your computer’s default text editor)

You can then add the item that you want to ignore.

If you don't have a .gitignore file yet, create a new file in your text editor. It is common to being the file with a comment, such as # Ignore the following

Underneath, list the items to be ignored, each on a separate new line, like this:


Be sure to save your file as .gitignore (the preceding period is important and there is no file extension), and then to add and commit this change.

The Git documentation goes into more detail with everything you need to know.

Still need help? Contact Us Contact Us