.gitignore

.gitignore is a text file that tells Git which files and folders to ignore, so they are never tracked or committed. It is used for things like build output, secrets, and dependency folders.

Git & DevOps

Each line is a pattern; matching files won't show up in git status or get added by accident. Common entries include node_modules/, .env, and *.log.

Ignoring files keeps your repository clean and prevents accidentally committing passwords or huge generated folders. Note that .gitignore only affects untracked files — already-committed files keep being tracked.

Examples

Bash

cat .gitignore

Output:

node_modules/
.env
*.log
dist/

Learn it in a lesson

See also

Back to the Dictionary