Ignoring files in subfolders, multiple .gitignore files

suggest change

Suppose you have a repository structure like this:

examples/
    output.log
src/
    <files not shown>
    output.log
README.md

output.log in examples/ is meant to stay in the project. The one under src/ is created while debugging and should not be committed.

There are two ways to ignore the file under src/. You can put a path relative to the repository root in the root .gitignore:

# /.gitignore
src/output.log

Alternatively, you can create a .gitignore file in the src/ directory and ignore the file that is relative to this .gitignore:

# /src/.gitignore
output.log

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents