Need Assistance?

support@tutorialshub.in

Git Fundamentals

Git ignore rules

ADVERTISEMENT
Git Free Lesson
5 min read
ADVERTISEMENT

Why .gitignore exists

The .gitignore file tells Git which untracked files and directories should normally be ignored. Typical examples include dependency directories, build output, editor settings, local environment files and generated logs.

Ignore generated data, not source code

A useful rule is to commit files required to reproduce the project and ignore files that are generated locally or contain machine-specific state. Never use .gitignore as a way to hide a secret that is already tracked.

If a file is already tracked

Adding a tracked file to .gitignore does not remove it from the repository. You must remove it from Git's index while deciding whether to keep the local file.

ADVERTISEMENT