Overview
The.gitignore integration feature allows Draw Folder Structure to automatically exclude files and folders that are already ignored by Git. This is perfect for creating clean documentation that only shows the relevant parts of your project.
By default, this feature is disabled. You need to enable it in your VS Code settings.
Why Use .gitignore Integration?
When documenting your project structure, you typically don’t want to include:node_modules/- Dependencies that bloat the outputdist/orbuild/- Compiled/generated files.envfiles - Environment variables- IDE-specific files -
.vscode/,.idea/ - OS files -
.DS_Store,Thumbs.db - Temporary files -
*.log,*.tmp
.gitignore, why duplicate them in the extension settings?
Enabling .gitignore Integration
- VS Code Settings UI
- settings.json
How It Works
WhenrespectGitignore is enabled, the extension:
- Looks for a
.gitignorefile in your project root - Parses all the ignore patterns defined in it
- Applies those patterns during structure generation
- Excludes any matching files and folders from the output
The extension uses the same ignore matching logic as Git, supporting all standard .gitignore patterns and syntax.
Example Comparison
See the difference between structures generated with and without .gitignore integration:Sample .gitignore File
.gitignore
Without .gitignore Integration
WhenrespectGitignore is false (default):
- All
node_modulesdependencies - The
distbuild folder .envand.DS_Storefilescoveragereports*.logfiles
With .gitignore Integration
WhenrespectGitignore is true:
- Configuration files
- Source code directory
- Actual application files
Use Cases
1. Repository Documentation
Creating README Project Structure
Creating README Project Structure
When documenting your repository in a README file, you want to show the source structure, not dependencies.Configuration:Result:
Only the committed source files appear in the structure, making your README clean and professional.
2. Architecture Documentation
Documenting Application Architecture
Documenting Application Architecture
When explaining your application’s architecture, you want to focus on the logical structure, not build artifacts.Configuration:Result:
A clean, professional structure showing only the architectural components.
3. Onboarding Documentation
Helping New Team Members
Helping New Team Members
New developers need to understand the source code structure, not the build system.Configuration:Result:
A beginner-friendly structure showing the core application code without tests or build artifacts.
4. PR Descriptions
Showing Changes in Pull Requests
Showing Changes in Pull Requests
When creating a pull request that restructures code, show only the relevant source structure.Configuration:Result:
Reviewers see the actual code organization without being distracted by dependencies or build files.
Combining with Exclude Patterns
You can use both.gitignore integration and custom exclude patterns together for maximum control:
settings.json
- Excludes everything from
.gitignore(dependencies, build files, etc.) - Additionally excludes test files and mock data
- Results in a super clean structure showing only production code
Common .gitignore Patterns
Here are common patterns that work well with the integration:- Node.js Projects
- Python Projects
- Java Projects
- Generic Projects
.gitignore
Best Practices
Keep .gitignore Updated
Regularly update your
.gitignore to include new build artifacts or dependencies. The extension will automatically pick up changes.Use for Documentation
Enable this feature specifically when generating structures for documentation. Disable it if you need to see all files for debugging.
Test Both Modes
Generate structures with and without .gitignore integration to see which gives you the view you need.
Combine with Recursion
For large projects, combine .gitignore integration with recursion control for optimal results:
Troubleshooting
.gitignore not being respected
.gitignore not being respected
Possible causes:Make sure the .gitignore file is at your project root level.
- Feature not enabled: Verify
respectGitignoreis set totruein settings - No .gitignore file: Make sure a
.gitignorefile exists in your project root - Pattern syntax: Check that your .gitignore patterns are valid
- Cache issues: Try reloading VS Code window (Cmd/Ctrl+Shift+P > “Reload Window”)
Too many files still showing
Too many files still showing
Issue: Even with .gitignore enabled, you’re seeing files you want to exclude.Solution: Combine .gitignore with custom exclude patterns:
Missing files I want to see
Missing files I want to see
Issue: .gitignore is excluding files you want in the structure.Solution: Either:
- Disable
respectGitignoretemporarily - Remove those patterns from .gitignore
- Use separate documentation-specific patterns in the exclude setting
Real-World Example
Let’s see a complete example from a typical VS Code extension project:Project .gitignore
.gitignore
Settings Configuration
settings.json
Generated Structure
└── 📁 draw-folder-structure
├── package.json
├── tsconfig.json
├── README.md
└── 📁 src
├── extension.ts
├── 📁 functions
├── generate-structure.ts
├── find-files.ts
└── get-prefix.ts
├── 📁 services
└── telemetry.ts
├── 📁 types
└── style.ts
└── 📁 assets
├── drawstructurelogo.png
└── screen01.png
Perfect for documentation! No
node_modules, no out folder, no build artifacts - just the source code structure.
Next Steps
Exclude Patterns
Learn about custom exclusion patterns for fine-grained control
All Settings
Explore all available configuration options
Custom Styles
Choose from 20+ visual styles for your structures