Excluding files with .deployignore

New Features, Tips & Tricks, and Tutorials

Excluding files with .deployignore

When deploying with DeployHQ, you'll often want to prevent certain files from reaching your server — development configs, build dependencies, test fixtures, and other files that belong in your repository but not on production. The .deployignore file gives you a version-controlled way to define these exclusion rules.

What is .deployignore?

A .deployignore file works similarly to .gitignore: you place it in the root of your repository, and DeployHQ reads it during each deployment to determine which files and directories should be excluded. It works with all supported version control systems — Git, Mercurial, and Subversion.

flowchart LR
    A[Repository Push] --> B[DeployHQ Detects Changes]
    B --> C{Read .deployignore}
    C --> D[Match Files Against Rules]
    D --> E[Excluded Files Skipped]
    D --> F[Remaining Files Deployed]
    F --> G[Server Updated]

Setting it up

Create a .deployignore file in the root of your repository and add one exclusion rule per line. Comments start with #:

@title: .deployignore
# Dependencies (installed on server via build commands)
node_modules
node_modules/**
vendor
vendor/**

# Environment and config files
.env
config/local.php
config/database.yml

# Build and test artifacts
tests
tests/**
coverage
coverage/**
**/*.log

# Development tools
.editorconfig
.eslintrc
.prettierrc
docker-compose.yml
Makefile

Once the file is pushed to your repository, DeployHQ will automatically check your rules and exclude the matched files from all future deployments.

Pattern syntax reference

The .deployignore file uses the same pattern syntax as the Excluded Files UI:

Pattern What it matches Example
filename A specific file or directory name Makefile, vendor
path/to/file A file at a specific path config/database.yml
*.ext Files with an extension in the current directory *.log
**/*.ext Files with an extension at any depth **/*.env
dir/** All contents inside a directory node_modules/**
dir/prefix-* Files matching a prefix in a directory config/test-*
!pattern Whitelist — keep a file even if its parent is excluded !vendor/autoload.php

Important notes:

  • To fully exclude a directory and its contents, you need two rules: one for the directory itself (vendor) and one for its contents (vendor/**)
  • Rules must not end with trailing slashes
  • Use ** to match files recursively at any depth

Common examples by project type

PHP / Laravel

@title: .deployignore (PHP/Laravel)
node_modules
node_modules/**
tests
tests/**
.env
.env.example
phpunit.xml
docker-compose.yml
**/*.log

Node.js / Express

@title: .deployignore (Node.js)
tests
tests/**
coverage
coverage/**
.env
.env.test
jest.config.js
**/*.test.js
**/*.spec.js
**/*.log

WordPress

@title: .deployignore (WordPress)
node_modules
node_modules/**
.env
wp-config-local.php
**/*.sql
**/*.log
docker-compose.yml

Static site / Frontend

@title: .deployignore (Frontend)
node_modules
node_modules/**
src
src/**
tests
tests/**
.env
**/*.map
**/*.test.*
webpack.config.js
tsconfig.json

.deployignore vs the Excluded Files UI

DeployHQ offers two ways to manage exclusions:

Feature .deployignore Excluded Files UI
Version controlled Yes — lives in your repository No — configured in DeployHQ
Per-server rules No — applies to all servers Yes — can differ per server
Whitelisting Yes — use ! prefix Yes — use ! prefix
Shared across team Yes — committed to repo No — per-account setting

If you need different exclusion rules for different servers (e.g. excluding test data from production but keeping it on staging), use the Excluded Files per Server feature in the UI.

For most teams, using .deployignore for project-wide rules combined with the UI for server-specific overrides is the recommended approach.

Verifying your rules

After running a deployment, check the deployment log under the Generate Manifest step. DeployHQ displays a full list of excluded files for each server, so you can confirm your rules are working as expected.

For the full documentation, see our support article on excluded files.


Ready to streamline your deployments? Sign up for DeployHQ and get started in minutes. If you have any questions, reach out to us at support@deployhq.com or on Twitter/X @deployhq.

A little bit about the author

Adam W. | Customer Support Specialist | Krystal | Exceptional Customer Experience - Known as "Batman" to colleagues and customers, Adam is dedicated to providing exceptional customer support at Krystal. Committed to positive customer experiences. Enjoys gaming, music, and running.