Integrating Git for whole site environment
Staq now supports Git integration if you have an entire website inside its own Git repository. This means you can manage plugins, themes, and additional files through Git and seamlessly deploy them into your Staq environment.
If you have a plugin or theme in a separate Git repo, please refer to these guides:
Git Integration with WordPress on Staq
Staq makes it easy to integrate Bitbucket or Github into any environment—production, development, or staging. You can even select which branch to sync!
How WordPress Git Integration Works on Staq
- Create or migrate your site (dev, staging, or production).
- If already live, simply integrate Git into your existing environment.
- For staging, create a staging site from the Staq Panel (optionally exclude plugins/themes if they are managed via Git).
Once ready, go to the site’s Staq Panel → Integrations → Git:

Step 1 – Enter Git Details
- Select Git service: GitHub or Bitbucket
- Enter repository URL and branch

Step 2 – Add SSH Keys
- Generate and copy the SSH Key.
- Paste it into your repository’s access keys and label it.

and paste the SSH key here. Also create the label name also:

Step 3 – Add Webhook
- Copy the webhook URL and add it to the repository’s webhooks.

Then, add your webhook URL and follow the prompts:

Step 4 – Final Setting
- Optionally Disable Auto-Updater which disables the Staq Plugin/Theme auto-updater for plugin/theme updates
- Disable Media Uploads Sync feature which disables the media uploads folder syncing from Git to your WordPress environment
- Purge Cache After Sync which clears the site’s front-end cache (includes Staq Cache and WP Rocket) and Redis Object Cache (if enabled)

Once the setup has been confirmed inside the Staq interface after clicking Connect Git, every time you push to the selected branch, the webhook triggers Staq to securely identify the branch and perform a pull operation automatically.
General Actions
- Disconnect Git: Disconnects your site from the Git repository.
- Event Logs: Allows you to see the history of events Staq listened and performed on your site.
- Force Pull: Manually triggers a pull and sync request as if your code was pushed.
- Save Options: Edits the existing options and updates the site’s behaviour.
What Happens Under the Hood?
When Git integration is enabled on Staq, the following process takes place to ensure stability, security, and consistency:
- /wordpress – This is your live WordPress directory that serves the site.
- /wordpress-git – A new isolated directory is created where your Git repository is cloned and updated.
- After each Git pull, Staq automatically runs a sync script that copies updated files from /wordpress-git into the live /wordpress directory.
This separation prevents conflicts between the Git repository and live files, ensuring you have full control over what gets deployed while keeping the live site protected during updates.
Important: During the sync process, files from /wordpress-git overwrite matching files in /wordpress. Any files not in Git are preserved unless explicitly managed. Core WordPress files and critical server files are automatically protected—see below.
What Files Are Ignored Automatically?
For security and consistency, Staq always excludes WordPress core files and hosting-specific files from syncing — even if you mistakenly push them to your Git repository.
Automatically excluded files and directories:
- # WordPress core files
- wp-includes/
- wp-admin/
- index.php
- xmlrpc.php
- license.txt
- readme.html
- wp-*.php
- wp-content/cache/
- wp-content/*backup*/
- wp-content/upgrade/
- wp-content/temp/
- # Hosting-specific files
- login.php
- .stq_*
- # Git repository itself
- .git/
This ensures that WordPress core files are always managed by Staq, and no accidental overwrites occur.
Note: Staq enforces an even stricter policy — a Core Files Integrity Scanner runs regularly to block any modification to core WordPress files, even if changes are made outside Git (via SFTP or plugins).
Optional: Use .deployignore to Exclude Additional Files
Beyond the automatic exclusions, you can control what files should not sync by adding a .deployignore file inside your Git repository.
This follows a simple rsync-compatible pattern — one path per line, with optional comments using #.
Example .deployignore file:
# Exclude user uploads wp-content/uploads # Exclude backup folders wp-content/*backups* # Exclude build artifacts wp-content/plugins/my-plugin/node_modules
Strongly recommended: Using .deployignore helps:
- Save disk space and prevent unnecessary storage costs
- Keep deployments clean and fast
- Avoid syncing large, dynamic content like uploads
How to Track Git Syncs
Inside Staq Panel → Git → Integrations, you can:
- View a complete Event Log of Git syncs (successful, pending, failed)
- Manually Force a Pull from Git if needed
- Disconnect Git integration if required
Does Staq Support Pipelines and CI/CD?
Yes — Staq supports flexible CI/CD workflows with both Bitbucket Pipelines and GitHub Actions. These tools let you automate your build and deployment processes, such as compiling assets, running tests, and pushing updates.
You have two main options for deploying built assets to your WordPress environment:
- Upload built assets via SFTP: During your pipeline (e.g., in Bitbucket Pipelines or a GitHub Action), compile and minify your assets (CSS/JS), then upload only the final build artifacts to
wp-content/uploads/via SFTP. This approach bypasses Git syncing entirely. This KB shows you the path to access Staq sFTP. - Commit built assets back to Git: Alternatively, you can compile assets within your CI/CD pipeline, commit the compiled files into your Git repository (e.g., into a
build/ordist/directory), and push the changes. Staq will then automatically pull and sync the updated Git branch to your site.
This flexibility allows teams to use the CI/CD tools they’re most comfortable with — whether you’re using Bitbucket Pipelines to run custom scripts or GitHub Actions to automate deployments, Staq adapts to your workflow.
Special Git Files Supported by Staq
Staq recognizes a special script: .stq_postdeploy inside your Git repo.
- After each Git pull, if a .stq_postdeploy file is detected, it runs each command inside it automatically.
- Commands are executed safely within your site’s container directory (e.g.,
/var/www/sites/[app]/). - Each command must be on a separate line. Lines starting with
#are treated as comments.
Example .stq_postdeploy file:
# Activate a plugin wp plugin activate my-custom-plugin
Note: Only approved safe commands (mostly WP-CLI commands) are permitted. Contact support if you need additional options.
How Are Composer Dependencies Handled?
After each Git pull, Staq automatically:
- Scans all
wp-content/plugins/*/andwp-content/themes/*/folders forcomposer.jsonfiles - Runs composer install inside each detected directory
This ensures your plugin and theme dependencies are automatically installed and ready — no manual steps needed!
Summary
- Simple and secure Git integration built for WordPress at scale
- WordPress core files are fully protected
- .deployignore and .stq_postdeploy offer total control over deployments
- Composer dependencies are automatically managed
- Full Git event logs and manual pull options in Staq Panel
- Compatible with CI/CD and pipeline workflows
Need some help?
We all do sometimes. Please reach out to our support team by dropping us a support ticket. We will respond fast.