2026-06-07

n8n Version Control: Git Workflows for Automation Teams

Stop losing workflow changes. Complete guide to n8n + Git: exporting workflows as JSON, structuring repos, branching strategies, CI/CD deployment, code review for automations, and disaster recovery. Version control your automations like software.

n8n Version Control: Git Workflows for Automation Teams

Software engineers have Git. Automation engineers usually have "workflow-backup-final-v3-(actually-final).json." Let's fix that.

n8n workflows are JSON files. That means they're Git-trackable, diffable, and reviewable. Here's how to version control your automations like professional software.

Why Version Control Automation

  • Rollback: Deploy a broken workflow? Revert to the last working version in 10 seconds.
  • Collaboration: Two people editing the same workflow? Git merge, not "who overwrote my changes?"
  • Audit trail: Who changed the Stripe webhook handler and when?
  • Disaster recovery: Server dies? Your entire automation suite is in Git. Redeploy in minutes.

Repository Structure

``` n8n-workflows/ ├── workflows/ │ ├── production/ │ │ ├── stripe-invoice.json │ │ ├── shopify-slack.json │ │ └── calendly-crm.json │ ├── staging/ │ │ └── (promoted here before production) │ └── development/ │ └── (work-in-progress) ├── credentials/ │ └── .gitignore # NEVER commit real credentials ├── scripts/ │ ├── export-all.sh # Export all workflows from n8n │ ├── deploy.sh # Deploy workflows to n8n │ └── validate.sh # Validate workflow JSONs ├── tests/ │ └── test-data/ # Fixture data for testing └── README.md ```

CRITICAL: Add credentials to .gitignore. Your workflow JSONs contain credential IDs, not the actual secrets. But never commit .env files or credential exports.

Exporting Workflows to Git

Manual Export (Getting Started)

In n8n UI: Workflow → Settings → Download → Save to workflows/production/

API Export (Automated)

```bash #!/bin/bash

scripts/export-all.sh

API_KEY="$N8N_API_KEY" BASE_URL="https://n8n.yourdomain.com/api/v1"

curl -s -H "X-N8N-API-KEY: $API_KEY" "$BASE_URL/workflows" | jq -r '.data[] | @base64' | while read encoded; do workflow=$(echo "$encoded" | base64 --decode) name=$(echo "$workflow" | jq -r '.name' | sed 's/[^a-zA-Z0-9]/_/g') echo "$workflow" | jq '.' > "workflows/production/${name}.json" echo "Exported: ${name}.json" done ```

Run this on a cron schedule or as a pre-commit hook.

Deploying from Git to n8n

```bash #!/bin/bash

scripts/deploy.sh — deploys all production workflows

API_KEY="$N8N_API_KEY" BASE_URL="https://n8n.yourdomain.com/api/v1"

for f in workflows/production/*.json; do name=$(basename "$f" .json) echo "Deploying: $name"

curl -s -X POST -H "Content-Type: application/json" -H "X-N8N-API-KEY: $API_KEY" -d "@$f" "$BASE_URL/workflows" > /dev/null

echo " ✓ Deployed" done ```

Branching Strategy

| Branch | Environment | Description | |---|---|---| | main | Production | Deployed to prod n8n. Only merge via PR. | | staging | Staging | Test before promotion. Auto-deploy on push. | | feat/* | Development | Individual workflow changes. Branch from main. |

Workflow

  1. Create feat/update-stripe-invoice from main
  2. Edit the workflow in n8n, export to Git, commit
  3. Open PR → team reviews the JSON diff
  4. Merge to staging → auto-deploy → run tests
  5. Merge to main → auto-deploy to production

Code Review for Automations

Reviewing workflow JSON diffs teaches you a lot. Look for:

  • Changed URLs: Did someone point a webhook at the wrong endpoint?
  • Removed error handling: Did someone delete the Error Trigger connection?
  • Hardcoded values: Numbers or strings that should be environment variables
  • New credentials: Added a new API connection? Did they document it?
  • Node position changes: Usually cosmetic, but large rearrangements might hide logic changes

CI/CD Pipeline Example

```yaml

.github/workflows/deploy.yml

name: Deploy n8n Workflows on: push: branches: [main] paths: ['workflows/**']

jobs: validate: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Validate JSON run: | for f in workflows/production/*.json; do jq '.' "$f" > /dev/null || { echo "Invalid: $f"; exit 1; } done

deploy: needs: validate runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Deploy to n8n Production run: bash scripts/deploy.sh env: N8N_API_KEY: ${{ secrets.N8N_API_KEY }} ```

Disaster Recovery

Your n8n server died. What now?

```bash

1. Spin up a new VPS (5 minutes)

2. Install Docker (2 minutes)

3. Deploy n8n (5 minutes)

4. Deploy all workflows from Git (30 seconds)

bash scripts/deploy.sh

5. Re-add credentials manually from your password manager (10 minutes)

Total recovery time: ~25 minutes

```

Without Git version control? Hope you had backups. Hope they're recent. Hope you remember which version was running.

Tips for Teams

  1. One workflow per file. Don't batch workflows into a single JSON.
  2. Meaningful filenames: stripe-payment-to-invoice.json, not workflow-7.json.
  3. README per directory: Document what each workflow does, its triggers, and its dependencies.
  4. Never force-push to main. Treat workflow history like code history.
  5. Tag releases: git tag v2026.06.07 before major deploys.

Your automation suite is critical infrastructure. Version control it accordingly.

All FlowForge templates come as clean, well-structured JSON — ready for Git. Import, customize, commit.

Related n8n Templates

These pre-built n8n templates complement what you just read. Import and run in minutes.

Ready to automate?

Browse 25+ production-ready n8n templates. Import, configure, and run — all in under 10 minutes.

Browse Templates