What Is a GITIGNORE File?

This file defines what Git should ignore

What to Know

  • A GITIGNORE file specifies which files to ignore in the Git revision control system.
  • Any text editor can view the contents of the file, but to actually use it, copy it to a folder in your repository.

This article explains what a GITIGNORE file is and how it's used, plus how you can open it on your computer.

What Is a GITIGNORE File?

A file with the GITIGNORE file extension is a Git Ignore file used with the version/source control system called Git.

This file specifies which files and folders should be ignored in a given source code. It can be used on a per-path basis so that the rules are only applied to specific folders, but you can also create a global GITIGNORE file that applies to every Git repository you have.

You can find dozens of examples of GITIGNORE files that are recommended in various scenarios, from GitHub's .gitignore templates page.

How to Open a GITIGNORE File

GITIGNORE files are plain text files, meaning you can open one with any program that can read text files.

Screenshot of several GITIGNORE files in Windows 10 that open with Notepad

If you're on Windows, you can use the built-in Notepad program, or Notepad++. To open one on macOS, use Gedit. Linux users (as well as Windows and macOS) might find Atom useful for opening and editing GITIGNORE files.

However, GITIGNORE files aren't actually usable (i.e., they don't function as an ignore file) unless they're utilized within the context of Git.

You can use the file by placing it wherever it is that you want the rules to apply. Put a different one in each working directory, and the ignore rules will work for each folder individually. If you put the GITIGNORE file in the root folder of the project's working directory, you can add all the rules there so that it takes on a global role.

Don't put the GITIGNORE file in the Git repository directory; that will not allow the rules to apply, since the file needs to be in the working directory.

GITIGNORE files are useful for sharing the ignore rules with anyone else who might clone your repository. This is why, according to GitHub, it's important to commit it into your repository.

You can use a site like gitignore.io to create GITIGNORE files for your project.

How to Convert To/From a GITIGNORE File

See this Stack Overflow thread for information on converting CVSIGNORE to GITIGNORE. The simple answer is that there isn't a regular file converter that can do it for you, but there might be a script you can use to copy over the patterns of the CVSIGNORE file.

See Convert SVN Repositories to Git Repositories for help doing that. Also, see this Bash script that might be able to achieve the same thing.

To save your GITIGNORE file to a text file format, use one of the text editors mentioned above. Most of them can convert to TXT, HTML, and similar plain text formats.

Advanced Reading on GITIGNORE Files

You can build a local GITIGNORE file from Terminal, with this command:

touch .gitignore

A global one can be made like this:

git config --global core.excludesfile ~/.gitignore_global

Alternatively, if you don't want to make a GITIGNORE file, you can add exclusions to your local repository by editing the .git/info/exclude file.

Here's a simple example of a GITIGNORE file that would ignore various files generated by the operating system:

.DS_Store .DS_Store? ._* .Trashes ehthumbs.db Thumbs.db

Here's an example that excludes LOG, SQL, and SQLITE files from the source code:


There are lots of pattern rules that must be followed in order to abide by the proper syntax rules that Git demands. You can read about these, and a lot more about how the file works, from the official GITIGNORE Documentation website.

Make sure to remember that if you've already checked in a file to not be ignored, and then later add an ignore rule for it in the GITIGNORE file, Git will not ignore the file until you untrack it with the following command:

git rm --cached nameofthefile

Still Can't Open the File?

If your file isn't working as described above, check that you're reading the file extension correctly. For example, if you can't open it with a text editor or if Git doesn't recognize the file, you might not really be dealing with a GITIGNORE file.

IGN is another ignore file, but it's in the RoboHelp Ignore List file format created by and used with Adobe RoboHelp for building Windows help documents. While the file might serve a similar function—to list words that are ignored from searches through the documentation—it can't be used with Git and doesn't follow the same syntax rules.

If your file doesn't open, research its file extension to learn what format it's in so that you can find the appropriate software that opens or converts it.

  • How do I see what is in my GITIGNORE?

    You can open the file with your chosen text editor. You can also use the git check-ignore pathname command to see whether a particular file is on the ignore list.

  • What is GITIGNORE and GITATTRIBUTES in Visual Studio?

    The GITIGNORE file lists items untracked by a Git repository, while the GITATTRIBUTES file specifies how to handle particular files based on the pathname. You can open and change both files in Visual Studio from Repository Settings > Ignore & Attributes Files.

  • How do I GITIGNORE a folder?

    If you want to ignore the contents of a particular directory, open your GITIGNORE file and type folder_name/.

Was this page helpful?