Skip to content
← Insights
Aug 11, 20264 min read

Put your n8n workflows in Git before you lose one

Scheduled JSON exports give n8n workflows a change history you can inspect when a production automation breaks. Test the restore before you need it.

Line diagram on a dark ground: one path splitting into three parallel tracks and rejoining, with small open circles at each split and merge

A server failure once wiped out a client automation. I had neither an export nor a backup to restore. Rebuilding it from memory took an afternoon; finding the missing 10% took another week in production.

Since then, I've kept automations under version control. The canvas is an interface to production code.

A workflow needs a change history

People who use Git for application code can still leave their n8n workflows outside it. Their application changes go through pull requests before reaching production.

In the workflow editor, saving fifteen nodes may update the only copy of a production pipeline. The previous version can disappear with that save.

A workflow that moves invoices does the job a script would do. The same is true of CRM synchronization or content publishing. Diagnosing a failure requires knowing what changed, even when the operations were built on a canvas. With a script, a diff can answer that question. Without workflow history, you're left trying to remember Tuesday's configuration.

Native source control has plan limits

n8n's native source control pushes workflows to a Git provider. It also exports tags with stubs for credentials and variables.

Two limits affect the setup.

The feature requires Enterprise. Community users, along with users on lower plans, need another export method. That affects solo operators who run n8n outside an Enterprise subscription.

The review interface remains in the Git provider. n8n's integration exports the workflow. Pull requests with diff review happen in the Git provider.

If your plan lacks the feature, you can schedule JSON exports into a repository you own.

Schedule the export

An official n8n template retrieves workflow JSON through the n8n API, then commits it to GitHub on a schedule.

The setup requires:

  • A private repository. Workflow JSON can expose internal endpoints or business logic.
  • A GitHub token with repository access, stored in n8n credentials.
  • The imported template configured for that repository.
  • A scheduled trigger. A daily export suits workflows that change infrequently.

I group the files by tag. Timestamped commit messages help me find the export I need.

Keep secrets outside the export

Each JSON file contains one workflow definition. It records the nodes with their connections, trigger configuration, settings, tags, and active flag.

Credential values stay in n8n. Execution history stays outside this workflow export too.

n8n's credential store encrypts secrets. Committing a token to make restoration easier would expose that secret through the repository's history. Restore the workflow definition first, then reconnect the required credential in n8n.

Execution history can contain customer data. Its volume also makes it unsuitable for this repository of workflow definitions.

Use the history during repairs

A sequence of exports lets you compare versions of the same workflow.

When a workflow fails on Thursday, Wednesday's diff gives you somewhere to start. Checking those changes has saved me time that I previously spent reconstructing events from memory.

An earlier export also gives you a specific working version to restore.

For a shared workflow, a pull request lets another person inspect the JSON before a production change. Reading the diff takes effort. It gives the team a review step before someone edits the live workflow late at night.

The repository also becomes an inventory of the client workflows I've exported. I can inspect it when I need to establish what we've been maintaining.

Test the restore

The export method has limits worth accounting for in the recovery procedure.

Moving a node on the canvas changes its position in the JSON. Those layout changes can obscure a logic change in the diff, so reviewing an export takes some familiarity with the format.

Restoration requires importing the JSON into n8n, then reconnecting credentials. A deliberate test establishes which steps your instance needs before a failure makes the restore urgent.

A daily schedule can leave up to a day of edits outside Git. I trigger an extra export after a substantial editing session.

Give production workflows a repository

Version control is an established engineering practice that also applies to canvas-based automation. A workflow's effect on a business depends on what it does, regardless of the interface used to build it.

If losing a workflow would take a week to recover from, a scheduled export is worth setting up before that happens.

I build and maintain automation systems for teams whose workflows have grown beyond what one person can keep in memory.

n8nautomationgitdevops