Typorithm · easy

.gitignore

gitignoregitignoreglob
Saved on this device
Full lesson · 8 learning steps Open any exercise for focused practice
1

Step 1 of 8 · intro card

Learn .gitignore

0%

Basics

.gitignore lists glob patterns Git should not track. A trailing slash matches directories, * is a wildcard, and a leading ! un-ignores (negates) a pattern. Files already tracked are not ignored until you git rm --cached them.

.gitignore is a plain-text file listing glob patterns for paths Git should never track — things like dependencies, build output, and secrets.

Patterns are flexible: a trailing slash (node_modules/) matches a directory, * is a wildcard (*.log matches any .log file), and a plain name (.env) matches that exact file. A leading ! negates a pattern, un-ignoring something a broader rule would have hidden.

One important gotcha: .gitignore only affects untracked files. A file Git already tracks keeps being tracked until you remove it from the index with git rm --cached, even after you add it to .gitignore.

01

A trailing slash matches a directory.

02

* is a wildcard; !pattern un-ignores.

03

Already-tracked files need git rm --cached to stop tracking.

node_modules/
*.log
.env
dist/
!keep.txt

Read the implementation

Connect each part of the code to the concept before you type.

1. Ignore a directory

A trailing slash matches a directory, so the whole node_modules folder is ignored.

node_modules/

2. Wildcard pattern

* is a wildcard, so *.log matches every file ending in .log.

*.log

3. A single file

A plain name like .env ignores that exact file (keeping secrets out of the repo).

.env

4. Build output

dist/ ignores the build-output directory, which is regenerated and need not be tracked.

dist/

5. Negate a pattern

A leading ! negates a pattern, un-ignoring keep.txt even if a broader rule would hide it.

!keep.txt

A complete learning loop

01

Understand

Read the concept map and follow the code breakdown.

02

Reconstruct

Type the implementation, repair mistakes and work through every recall exercise.

03

Verify

Use the final check without hints; revisit weak concepts in short practice sessions.

.gitignore: Lesson & Practice · Typorithm | ApplyDjinn