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. 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. 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 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: A global one can be made like this: 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: 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:

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.