7.1 KiB
7.1 KiB
.gitignore Templates for Common Programming Languages
Universal .gitignore (Good for any project)
# Operating System Files
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
# Editor Files
.vscode/
.idea/
*.swp
*.swo
*~
.project
.classpath
.settings/
# Log Files
*.log
logs/
log/
# Environment Files
.env
.env.local
.env.development
.env.test
.env.production
.env.staging
*.secret
config.local.js
# Temporary Files
*.tmp
*.temp
temp/
tmp/
*.bak
*.backup
# Archive Files
*.zip
*.tar.gz
*.rar
*.7z
# System Files
desktop.ini
Python Projects
# Universal files first (copy from above)
# Python-specific
__pycache__/
*.py[cod]
*$py.class
*.so
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
.python-version
# Virtual environments
venv/
env/
ENV/
env.bak/
venv.bak/
.virtualenv
# Conda
.conda/
# Django
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask
instance/
.webassets-cache
# Scrapy
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
.pybuilder/
target/
# Celery
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
JavaScript/Node.js Projects
# Universal files first (copy from above)
# Dependencies
node_modules/
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Coverage directory used by tools like istanbul
coverage/
*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage
.grunt
# Bower dependency directory
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons
build/Release
# Dependency directories
jspm_packages/
# Snowpack dependency directory
web_modules/
# TypeScript cache
*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional stylelint cache
.stylelintcache
# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# parcel-bundler cache
.cache
.parcel-cache
# Next.js build output
.next
out
# Nuxt.js build / generate output
.nuxt
dist
# Gatsby files
.cache/
public
# Storybook build outputs
.out
.storybook-out
# Temporary folders
.tmp
# React
build/
# Vue.js
dist/
# Webpack
.webpack/
# Babel
.babel_cache/
Java Projects
# Universal files first (copy from above)
# Compiled class file
*.class
# Log file
*.log
# BlueJ files
*.ctxt
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar
# virtual machine crash logs
hs_err_pid*
# Maven
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
.mvn/wrapper/maven-wrapper.jar
# Gradle
.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/
# IntelliJ IDEA
.idea/
*.iws
*.iml
*.ipr
out/
!**/src/main/**/out/
!**/src/test/**/out/
# Eclipse
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/
# NetBeans
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
# VS Code
.vscode/
# Spring Boot
spring-boot-*.log
C/C++ Projects
# Universal files first (copy from above)
# Prerequisites
*.d
# Object files
*.o
*.ko
*.obj
*.elf
# Linker output
*.ilk
*.map
*.exp
# Precompiled Headers
*.gch
*.pch
# Libraries
*.lib
*.a
*.la
*.lo
*.dll
*.so
*.so.*
*.dylib
# Executables
*.exe
*.out
*.app
*.i*86
*.x86_64
*.hex
# Debug files
*.dSYM/
*.su
*.idb
*.pdb
# Kernel Module Compile Results
*.mod*
*.cmd
.tmp_versions/
modules.order
Module.symvers
Mkfile.old
dkms.conf
# CMake
CMakeLists.txt.user
CMakeCache.txt
CMakeFiles
CMakeScripts
Testing
Makefile
cmake_install.cmake
install_manifest.txt
compile_commands.json
CTestTestfile.cmake
_deps
# Build directories
build/
debug/
release/
Go Projects
# Universal files first (copy from above)
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
# Test binary, built with `go test -c`
*.test
# Output of the go coverage tool
*.out
# Dependency directories
vendor/
# Go workspace file
go.work
go.work.sum
# Build output
bin/
pkg/
dist/
# Air (live reload)
tmp/
# GoLand
.idea/
# VS Code Go extension
.vscode/
Web Development (HTML/CSS/JS)
# Universal files first (copy from above)
# Sass
.sass-cache/
*.css.map
*.sass.map
*.scss.map
# Less
*.css.map
# Bundle files
bundle.js
bundle.css
# Compiled CSS from preprocessors
*.compiled.css
# npm/yarn
node_modules/
package-lock.json
yarn.lock
# Webpack
dist/
.webpack/
# Parcel
.cache/
.parcel-cache/
# Build tools
.grunt/
.gulp/
# Static site generators
_site/
.jekyll-cache/
.jekyll-metadata
# PWA
sw.js
workbox-*.js
Docker Projects
# Universal files first (copy from above)
# Docker
.dockerignore
docker-compose.override.yml
.docker/
# Container runtime files
*.pid
*.log
# Docker volumes
data/
volumes/
Recommended Usage Instructions
- Start with Universal: Always begin with the universal .gitignore section
- Add Language-Specific: Append the appropriate language-specific section
- Customize for Your Project: Add any project-specific files or directories
- Keep It Updated: Review and update your .gitignore as your project evolves
Creating .gitignore Files
Method 1: Manual Creation
# Navigate to your project root
cd your-project
# Create .gitignore file
touch .gitignore
# Edit with your preferred editor
nano .gitignore # or code .gitignore for VS Code
Method 2: Use gitignore.io
Visit https://gitignore.io and generate custom .gitignore files for your stack.
Method 3: GitHub Templates
When creating a repository in Gitea, you can initialize with a .gitignore template for common languages.
Tips for .gitignore Management
- Add .gitignore early: Create it before your first commit
- Test your patterns: Use
git statusto verify files are being ignored - Use comments: Document why certain patterns are included
- Be specific: Avoid overly broad patterns that might exclude needed files
- Global gitignore: Consider setting up a global .gitignore for OS-specific files
Setting up Global .gitignore
# Create global gitignore file
git config --global core.excludesfile ~/.gitignore_global
# Add common files to global ignore
echo ".DS_Store" >> ~/.gitignore_global
echo "Thumbs.db" >> ~/.gitignore_global
echo "*.log" >> ~/.gitignore_global