Repaso
EspaƱol

What is the purpose of a .gitignore file?

Options

  1. To store the access passwords of the repository
  2. To list files Git must not track, like build output (Correct option)
  3. To delete files from the repository automatically
  4. To rename the branches of the repository in bulk

Answer

To list files and folders Git should not track (build output like target/, IDE settings, secrets, logs)

Why

Some files should never be in the repository: compiled output (target/, node_modules/), IDE folders (.idea/), logs, and above all secrets such as .env files with passwords.

List patterns in .gitignore and Git will not stage them. Note: it does not remove files already tracked; use git rm --cached file for those.

If a secret was committed, treat it as leaked: rotate it, since history keeps it.

target/
.idea/
*.log
.env

Remember

.gitignore keeps build output and secrets out of the repo.

Key terms

Practice this question in Repaso