3

If I have set a global .gitignore file and my project also has a .gitignore file and they both contain different content, do entries from both of them get used in my project?

Community
  • 1
  • 1
leeand00
  • 25,510
  • 39
  • 140
  • 297

1 Answers1

2

Yes.

Together they will ignore the (union of) files they say to ignore.

This can be useful, for example:

  • Globally ignore emacs/vi/whatever temp files (per local tooling)
  • Project ignore build artifacts
user2864740
  • 60,010
  • 15
  • 145
  • 220
  • 1
    Keep in mind that `.gitignore` files also work hierarchically within a repo. So a `.gitignore` in the root of a repo will ignore things for the whole repo, but a `.gitignore` to ignore `*.so`files within, for instance, a `build` directory of a repo will only ignore those types of files in `build` and anything below it. This lower `.gitignore` is unioned with any other `.gitignore` files higher up in the directory structure. – eestrada May 11 '16 at 21:15