

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 5
click for more info
Not enough gems
Cost: 6 gems
1: Gitignore
incomplete
2: Nested Gitignore
incomplete
3: Patterns
incomplete
4: What to Ignore
incomplete
This lesson's interactive features are locked, please to keep using them
It would be rough if .gitignore files only accepted exact filepath section names. Luckily, they don't!
Let's go over some of the most common patterns.
The * character matches any number of characters except for a slash (/). For example, to ignore all .txt files, you could use the following pattern:
*.txt
This would ignore files like /princess_diaries.txt and /contacts/your_mom.txt since they're both .txt files.
Patterns starting with a / are anchored to the directory containing the .gitignore file. For example, this would ignore a main.py in the root directory, but not in any subdirectories:
/main.py
This ignores /main.py but not /src/main.py since /src is a subdirectory.
You can negate a pattern by prefixing it with an exclamation mark (!). For example, to ignore all .txt files except for important.txt, you could use the following pattern:
*.txt
!/important.txt
This would not ignore /important.txt, but would ignore /self_affirmations/important.txt.
You can add comments to your .gitignore file by starting a line with a #. For example:
# Ignore all .txt files
*.txt
Comments are especially helpful when doing something unconventional or complex, especially when collaborating.
The order of patterns in a .gitignore file determines their effect, and patterns can override each other. For example:
temp/*
!temp/instructions.md
Everything in the temp/ directory would be ignored except for instructions.md. If the order were reversed, instructions.md would be ignored.
You can read more about the patterns that are available in the official documentation.
Use this .gitignore file (located at the project root) to answer the question:
# *.js
*.txt
!names.txt
/src/main.py
content.md