Skip to content

Ignore Files and Folders

Eric Bouchut edited this page May 30, 2018 · 12 revisions

Ignore Files and Folders

Edit the file:

  • .git/info/exclude to ignore files that exists only in your local repository. (for example temporary files generated by a local smoke test you are the only one to use). .git/info/exclude is not under version control. Use it to ignore files specific to your local configuration.

  • .gitignore to ignore files in your local repository and in any clone of your repository. (This file contains files (and folders) ignored by default for anyone cloning (or pulling from) this repository) .gitignore is under version control and shared by anyone using the repository. Once commited and pushed to the repository, file exclusion configured in .gitignore applies to whoever uses the repository.

The exclusion rule for a file/folder must be added in either of these files, before git begins tracking it. If you need to ignore a file after git started tracking it, see git update-index --assume-unchanged below.

You can also define a global gitignore file that will apply to whatever repository.

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

Github contains a list of per language gitignore file templates: https://github.com/github/gitignore/tree/master/Global Use it as an inspiration as to what to put in ~/gitignore_global.

List ignored files

List the ignore/exclusion rules as defined in .gitignore and .git/info/exclude.

git status --ignored

 .agignore
 .bundle/
 .idea/
 public/docs/.DS_Store
 tags

If you have trouble remembering the above command, you use create this handy alias:

git config --global  alias.ignored  "status --ignored"

# From now on you can use the following instead
git ignored

Clone this wiki locally