5

When I want to add an entire directory to my .gitignore, what is the syntax? The directory-to-ignore is in my root directory.

Should it be:

1) directory-to-ignore

2) directory-to-ignore/

3) directory-to-ignore/*

Don P
  • 60,113
  • 114
  • 300
  • 432
  • 1
    possible duplicate of [Ignoring directories in Git repos on Windows](http://stackoverflow.com/questions/343646/ignoring-directories-in-git-repos-on-windows) – ollo Mar 09 '13 at 11:30

1 Answers1

7

just add the directory to the .gitigore like:

.gitignore file:

directory-to-ignore/

so, option 2 is correct

AdamT
  • 6,405
  • 10
  • 49
  • 75
  • 1
    yep. what he said. here's another same S.O. question and answer: http://stackoverflow.com/questions/343646/ignoring-directories-in-git-repos-on-windows/343734#343734 –  Mar 09 '13 at 04:33
  • @oyvey, oy vey! nice find. yom tov. – AdamT Mar 09 '13 at 04:36
  • since the OP mentions that the folder is in his [repo's] root directory, it might be worth adding that a leading slash will prevent other subfolders of the same name to be ignored (i.e. `/directory-to-ignore/`) – Nevik Rehnel Mar 09 '13 at 15:10