This guide explains the comprehensive .gitignore, .gitattributes, and .dockerignore files used in this TypeScript Excel devcontainer project.
- Overview
- .gitignore Categories
- .gitattributes Configuration
- .dockerignore Optimization
- Project-Specific Rules
- Best Practices
The project includes three configuration files to optimize Git and Docker operations:
.gitignore- Tells Git which files to ignore.gitattributes- Controls line ending normalization and file handling.dockerignore- Optimizes Docker builds by excluding unnecessary files
# Dependencies
node_modules/
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
# Build outputs
dist/
build/
out/
coverage/
# TypeScript
*.tsbuildinfo# VS Code
.vscode/
*.code-workspace
# IntelliJ/WebStorm
.idea/
*.iml
# Sublime Text
*.sublime-project
*.sublime-workspace
# Vim/Emacs
*.swp
*.swo
*~# macOS
.DS_Store
.AppleDouble
.LSOverride
# Windows
Thumbs.db
ehthumbs.db
Desktop.ini
# Linux
*~# Environment variables
.env
.env.local
.env.development.local
.env.test.local
.env.production.local
# Configuration overrides
config.local.js
config.local.json
settings.local.json# Office files
*.xlsx
*.xls
*.csv
*.manifest.xml
*.webmanifest
# Excel Add-in specific
*.xlsx
*.xls
*.csv# Keep project structure but ignore build artifacts
projects/*/node_modules/
projects/*/dist/
projects/*/build/
projects/*/coverage/
# Keep templates but ignore their build artifacts
templates/*/dist/
templates/*/build/
templates/*/coverage/
templates/*/node_modules/
# Keep examples but ignore their build artifacts
examples/*/dist/
examples/*/build/
examples/*/coverage/
examples/*/node_modules/# Set default behavior to automatically normalize line endings
* text=auto
# Force Unix line endings for shell scripts
*.sh text eol=lf
*.bash text eol=lf
# Force Windows line endings for batch files
*.bat text eol=crlf
*.cmd text eol=crlf# Text files with Unix line endings
*.json text eol=lf
*.js text eol=lf
*.ts text eol=lf
*.html text eol=lf
*.css text eol=lf
*.md text eol=lf
# Binary files
*.png binary
*.jpg binary
*.jpeg binary
*.gif binary
*.ico binary
*.zip binary
*.tar.gz binary# Large design files
*.psd filter=lfs diff=lfs merge=lfs -text
*.ai filter=lfs diff=lfs merge=lfs -text
*.sketch filter=lfs diff=lfs merge=lfs -text# Git files
.git
.gitignore
.gitattributes
# Documentation
README.md
docs/
*.md
# Node.js
node_modules/
npm-debug.log*
# Build outputs
dist/
build/
out/
coverage/
# IDE files
.vscode/
.idea/
# OS files
.DS_Store
Thumbs.db
# Environment files
.env
.env.*
# Project artifacts
projects/*/node_modules/
projects/*/dist/
projects/*/build/
# Essential files
!DevContainer/
!scripts/
!package.json
!package-lock.json
- Ignores build artifacts in
projects/,templates/, andexamples/directories - Keeps source code and configuration files
- Excludes IDE and OS-specific files
- Ignores Office file types (
.xlsx,.xls,.csv) - Excludes manifest and webmanifest files
- Handles Node.js and npm artifacts
- Normalizes line endings for different operating systems
- Handles Windows, macOS, and Linux specific files
- Ensures consistent behavior across platforms
- Review
.gitignoreregularly to ensure it covers new file types - Remove unnecessary rules that are no longer relevant
- Test with
git status --ignoredto verify rules work correctly
- Use project-specific
.gitignorefiles in subdirectories when needed - Document any special ignore rules in project README files
- Consider using
.gitignoretemplates for new projects
- Keep
.dockerignoreminimal but effective - Only exclude files that are truly unnecessary for the build
- Test Docker builds to ensure all required files are included
- Use
.gitattributesto enforce consistent line endings - Test on different operating systems to ensure compatibility
- Consider using pre-commit hooks to enforce line ending rules
- Use Git LFS for large binary files
- Document LFS usage in project documentation
- Monitor repository size and LFS usage
# Show ignored files
git status --ignored
# Check if a specific file is ignored
git check-ignore -v path/to/file
# List all ignored files
git ls-files --others --ignored --exclude-standard# Force add a file that's normally ignored
git add -f path/to/file
# Force add all files (use with caution)
git add -f .# Check line ending normalization
git ls-files --eol
# Test attribute processing
git check-attr -a path/to/file# Test Docker build with current .dockerignore
docker build -t test-image .
# Check what files are being sent to Docker daemon
docker build --no-cache -t test-image . 2>&1 | grep "Sending build context"- Check if the file was already tracked before adding to
.gitignore - Use
git rm --cached filenameto untrack without deleting - Verify
.gitignoresyntax and placement
- Check
.gitattributesconfiguration - Use
git config core.autocrlfto verify settings - Consider using
git add --renormalize .to fix line endings
- Verify
.dockerignoresyntax - Check if required files are being excluded
- Test with
docker build --no-cacheto see full context
- Git Ignore Documentation
- Git Attributes Documentation
- Docker Ignore Documentation
- Git LFS Documentation
Note: These configuration files are designed to work well with the TypeScript Excel devcontainer environment. Adjust them as needed for your specific project requirements.