Git Ignoring Files and Folders Ignoring files in subfolders (Multiple gitignore files)

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

Suppose you have a repository structure like this:

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

output.log in the examples directory is valid and required for the project to gather an understanding while the one beneath src/ is created while debugging and should not be in the history or part of the repository.

There are two ways to ignore this file. You can place an absolute path into the .gitignore file at the root of the working directory:

# /.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


Got any Git Question?