This version of GitHub Enterprise will be discontinued on This version of GitHub Enterprise was discontinued on 2020-01-22. No patch releases will be made, even for critical security issues. For better performance, improved security, and new features, upgrade to the latest version of GitHub Enterprise. For help with the upgrade, contact GitHub Enterprise support.

Ignoring files

From time to time, there are files you don't want Git to check in to GitHub Enterprise. There are a few ways to tell Git which files to ignore.

In this article

Create a local .gitignore

If you create a file in your repository named .gitignore, Git uses it to determine which files and directories to ignore, before you make a commit.

A .gitignore file should be committed into your repository, in order to share the ignore rules with any other users that clone the repository.

GitHub maintains an official list of recommended .gitignore files for many popular operating systems, environments, and languages in the github/gitignore public repository. You can also use gitignore.io to create a .gitignore file for your operating system, programming language, or IDE. For more information, see the gitignore.io site.

  1. In Terminal, navigate to the location of your Git repository.
  2. Enter touch .gitignore to create a .gitignore file.

The Octocat has a Gist containing some good rules to add to this file.

If you already have a file checked in, and you want to ignore it, Git will not ignore the file if you add a rule later. In those cases, you must untrack the file first, by running the following command in your terminal:

$ git rm --cached FILENAME

Create a global .gitignore

You can also create a global .gitignore file, which is a list of rules for ignoring files in every Git repository on your computer. For example, you might create the file at ~/.gitignore_global and add some rules to it.

  1. Open Terminal.
  2. Run the following command in your terminal:

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

The Octocat has a Gist containing some good rules to add to this file.

Explicit repository excludes

If you don't want to create a .gitignore file to share with others, you can create rules that are not committed with the repository. You can use this technique for locally-generated files that you don't expect other users to generate, such as files created by your editor.

Use your favorite text editor to open the file called .git/info/exclude within the root of your Git repository. Any rule you add here will not be checked in, and will only ignore files for your local repository.

  1. In Terminal, navigate to the location of your Git repository.
  2. Using your favorite text editor, open the file .git/info/exclude.

Further Reading

Ask a human

Can't find what you're looking for?

Contact us