← Back to Mission Control

Cargo Manifest

7 min read

The .gitignore File

Mission Phase 14 • Difficulty: Beginner

Excluding Non-Essential Cargo

Not everything belongs in version control. Build artifacts, logs, secrets, and temporary files should stay out. The .gitignore file tells Git what to ignore.

Creating .gitignore

Create a file named .gitignore in your repository root:

touch .gitignore

Common Patterns

# Dependencies
node_modules/
venv/
__pycache__/

# Build outputs
dist/
build/
*.exe
*.dll

# Logs
*.log
logs/

# Environment variables
.env
.env.local

# IDE files
.vscode/
.idea/
*.swp

# OS files
.DS_Store
Thumbs.db

# Temporary files
*.tmp
temp/

Pattern Rules

Examples

*.log              # Ignore all .log files
build/             # Ignore build directory
!important.log     # But track this one
**/temp            # Ignore temp in any subdirectory
/*.txt             # Ignore .txt files in root only

Language-Specific Templates

GitHub provides .gitignore templates for many languages at github.com/github/gitignore.

Global Ignore

Ignore files across all repositories:

git config --global core.excludesfile ~/.gitignore_global

When to Use

Ignore:

Don't ignore:

Already Tracked Files

If you add a file to .gitignore after tracking it:

git rm --cached filename

This removes it from Git but keeps the local file.

Checking Ignore Status

git status --ignored    # Show ignored files
git check-ignore -v filename  # Why is this ignored?

Common Mistake: Committing Secrets

Never commit API keys, passwords, or secrets. Add them to .gitignore before committing! If you accidentally commit secrets, they're in Git history forever—you must rotate the credentials.

Next: Secure Communications

Your manifest is configured. Next, we'll set up SSH keys for secure, password-free communication with GitHub.