48

I have this directory structure

./bin/<java class files>
./sometool/bin/<files for the tool>

...as well as some other files and directories.

It seens that if I want to avoid tracking the java class files, I should add this to the .gitignore file:

bin/

However, it appears that this also ignores the path ./sometool/bin

Is that correct, and if so, how do I get the behavior I want.

CharlesB
  • 86,532
  • 28
  • 194
  • 218
Anders Johansen
  • 10,165
  • 7
  • 35
  • 52

1 Answers1

86

I think paths in .gitignore have their root at the project's root, so you may try /bin

EDIT

And by the way, this is normal behaviour from git.

  • 67
    not entirely correct, but quite so. paths in `.gitignore` have their root at the folder containing the `.gitignore` (you can have one `.gitignore` per folder if you want). So putting a `.gitignore` with contents `/bin` will make it ignore files or folders named `bin` in th esame folder as the `.gitignore`. If you want to specify that `bin` should be a folder, then put a trailing slash. To sum it up, using `/bin/` will ignore only the `bin` folder in the same folder of the `.gitignore` file. – Carlos Campderrós Feb 26 '13 at 09:12
  • 2
    Thanks for the clarification, always good to learn things right. –  Feb 26 '13 at 09:15