How do I include gitignored files in a local-preview?
Last updated: July 14, 2025
Context
When using `spacectl stack local-preview`, files and directories listed in .gitignore are excluded from the preview. However, there may be situations where you want to include specific gitignored files or directories in your local preview, such as development-specific bind mounts or local configurations.
Answer
There are two approaches to handle gitignored files in local-preview:
Option 1: Disregard .gitignore completely
You can use the `--disregard-gitignore true` flag to completely ignore the .gitignore file:
spacectl stack local-preview --disregard-gitignore trueWhen using this flag, Spacelift will:
Ignore all rules in your .gitignore file
Only respect rules defined in .terraformignore
Note: This approach will include ALL files that would normally be gitignored, including potentially large directories like .terraform. Make sure to define exclusions in .terraformignore for files you still want to ignore.
Option 2: Request selective inclusion feature
Currently, there isn't a built-in way to selectively include specific gitignored files or directories. If you need this functionality, you can request this feature through: