MicrolearnENPTES

Ignore files with .gitignore

Lesson 8 of 24 · Git.Micro

Some files should never be committed: logs, build output, downloaded libraries. List them in a .gitignore file and Git stops offering them.

Each line of .gitignore is a pattern: *.log matches every file ending in .log.

A name ending in / matches a folder and everything inside it, like node_modules/.

.gitignore is a normal file: commit it so the whole team ignores the same things.

Create the file with echo "*.log" > .gitignore and add lines with >>, or type edit .gitignore to open the editor.

Check yourself

Which .gitignore line ignores the whole build folder?

Make Git ignore every .log file and the node_modules/ folder, then commit .gitignore with the message Ignore logs and dependencies.

Last commit message: “Ignore logs and dependencies”

Do it in the browser: a real Git tool, a short mission and instant feedback. No install.

Start this lesson — free
← Take a file out of the staging areaBranches are pointers →

All lessons · Git.Micro