Instead of starting from scratch with every new project, this boilerplate provides a solid foundation that ignores:
- Operating System files:
.DS_Store,Thumbs.db, and other system artifacts. - Logs & Temp files: Common log formats and temporary directories.
- Editor & IDE configs: VS Code, JetBrains (IntelliJ/PyCharm), Sublime Text, and others.
- Node.js:
node_modules/, build outputs, and dependency caches. - Python:
__pycache__, virtual environments (venv/,.env), and build artifacts.
There are a few easy ways to grab this file for a new project.
This is the quickest way. Navigate to your project's root directory in the terminal and run the following command.
curl -L -o .gitignore https://raw.githubusercontent.com/KnowOneActual/gitignore-boilerplate/main/.gitignoreYou can clone this repository to your local machine and copy the file from there.
- First, clone the repository. This creates a new folder named "gitignore-boilerplate".
git clone https://github.com/KnowOneActual/gitignore-boilerplate.git- Then, copy the file from the new folder to your project's location.
cp gitignore-boilerplate/.gitignore /path/to/your/new-project/You can also just view the .gitignore file on GitHub, click the "Raw" button, and save the page's contents into a .gitignore file in your project.
This file is a great starting point, but feel free to edit it to fit the specific needs of your project. You can add project-specific ignores at the bottom or remove sections you don't need (like the Python section if you are only working in Node).
Sometimes you might add a file to .gitignore after it has already been committed to your repository. Git will continue to track that file even though it matches a rule in your ignore file.
To fix this, you need to remove the files from the Git index (the cache) and then re-add them.
Be sure to commit any pending changes before running these commands.
# 1. Remove everything from the index (your actual files are safe)
git rm -r --cached .
# 2. Re-add everything. This time, Git will respect the .gitignore rules.
git add .
# 3. Commit the "refresh"
git commit -m "Refresh .gitignore to apply new rules"This project is licensed under the MIT License - see the LICENSE file for details.
