Learn how to use a .gitignore file to exclude certain files and directories from being tracked.
A `.gitignore` file is a simple text file where you list files and directories that you want Git to ignore. Git will not track changes to these files, nor will they show up in `git status` as untracked. This is extremely useful for preventing certain types of files from being accidentally committed to the repository. Common examples of files to ignore include compiled code (like `.o` or `.exe` files), log files, build artifacts, and dependency directories (like `/node_modules` or `/vendor`). You should also ignore files containing sensitive information, such as API keys or passwords. The `.gitignore` file should be placed in the root directory of your repository and committed like any other file, so that the ignore rules are shared with all collaborators. You can use patterns to ignore multiple files, such as `*.log` to ignore any file ending with `.log`, or specify entire directories by adding their name followed by a slash, like `build/`.