Home / The following paths are ignored by one of your .gitignore files – but there isn’t one

The following paths are ignored by one of your .gitignore files – but there isn’t one

When trying to add some files to an images directory under git source control, my new files wouldn't show up and I kept getting the response "The following paths are ignored by one of your .gitignore files" but I didn't have any .gitignore files, as far as I could tell. It turned out that I had rules in my global gitignore so this post documents where to look when you get this error.

What I did

I ran the following command:

git add images

where "images" was the name of the directory I wanted to add. The following response came back:

The following paths are ignored by one of your .gitignore files:
themes/mytheme/images
Use -f if you really want to add them.
fatal: no files added

But there was no .gitignore file in this project. It turned out that I'd unintentionally added ignore rules to my global gitignore configuration using the GUI git tool I use. This is at ~/.gitignore_global

Where does git look for ignore rules?

  1. ~/.gitignore_global
  2. The repository's .gitignore This is usually in the repository root, but there can be multiple .gitignore files. Do "find [repository directory] -name .gitignore" to find them.
  3. In the repository's .git/info/exclude This are not committed so is not shared with other developers on the project. Rules in here are useful for locally generated files you don't expect other users to generate.
  4. Anywhere else? Please comment below.