.gitignore files tell Git what not to add to the repository during commits. Usually what we put in our .gitignore:
- Final builds/executables — usually these are platform-specific or don’t reflect a release version. Better to rebuild locally or use a consistent CD pipeline to distribute code instead of checking it into version control.
- Intermediate files — most compilers and interpreters will output cache or intermediate binary files (like object files). We exclude them for the same reason we exclude our final builds.
- Virtual environment — in Python and JavaScript, it’s common to work with an isolated instance of our interpreter with locally downloaded packages. These may also be platform-specific, is generally not our code, and the versioning should be resolved by our package manager, not us, for a consistent development environment. It’s better to use a requirements.txt (or analogous) to list out packages for a fully reproducible environment.