.gitignore — files Git should ignore
A plain-text file at your repo root listing patterns Git won't track: `node_modules/`, `.env`, build artifacts. Without it your repo bloats with noise.
Most projects have files you don't want in Git: dependencies (node_modules/), secrets (.env), build outputs (dist/, .next/), OS junk (.DS_Store). They're large, generated, or sensitive.
Create a file called .gitignore at the root of your repo. List one pattern per line. Git won't track anything matching those patterns.
Common starter for a Node project:
node_modules/ .env .env.local dist/ build/ .DS_Store *.log
Already-tracked files don't get ignored automatically. If you add secret.txt then put it in .gitignore later, you need to untrack it first: git rm --cached secret.txt. Then commit. Going forward, it's ignored.
Tip: the website gitignore.io generates a ready-made .gitignore for any tech stack — pick node, python, macos and it builds the right list for you.
Practice
Type the command that *stops tracking* `secret.txt` in Git but keeps the file on disk.
Practice
Match the .gitignore patterns:
Ignore every `.log` file: Ignore the build output folder only:
Grounded on https://git-scm.com/docs/gitignore
Next up
Branches — parallel timelines
A branch is a named pointer to a commit. Cheap to create, cheap to delete. You branch off `main` to work on a feature, then merge back when done.