What Is a GITIGNORE File?

How to open, edit, and convert GITIGNORE files

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

A file with the GITIGNORE file extension is a Git Ignore file used with the version/source control system called Git. It specifies which files and folders should not 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.

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

However, GITIGNORE files are not actually usable (i.e. they don't function as an ignore file) unless they're utilized within the context of Git, which is free software that runs on Windows, Linux, and macOS.

You can use the GITIGNORE 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.

Note: Do not 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.

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 How to 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:

._* .Trashes

Here's a GITIGNORE 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

Is Your File Still Not Opening?

If your file isn't working like 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 is 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.

Was this page helpful?