Bidirectional Synchronization for Workflow Version Control using GitHub - n8n Workflow

Automate bidirectional syncing of your n8n workflows with GitHub for robust version control, backup, and collaborative development using this advanced n8n template.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Automation Developers who need reliable version control for their complex n8n workflow logic.
Teams using n8n that require synchronized environments and collaborative access to n8n templates.
Users needing robust, scheduled backups of their n8n instance configurations.
Technical users looking for advanced examples of flow control and API interaction within an n8n workflow.

Overview

This comprehensive n8n workflow addresses the critical need for version control and reliable backup of crucial n8n templates and automations. Developers and advanced n8n users often struggle to keep their local n8n workflow definitions synchronized with external repositories, making collaboration and disaster recovery difficult. This specialized n8n template uses a sophisticated bidirectional approach: it compares every local n8n workflow against its corresponding file on GitHub. If a workflow only exists in n8n, it uploads it to GitHub. If a workflow only exists on GitHub, it imports it into n8n. Most importantly, it intelligently resolves version conflicts by checking timestamps, ensuring the most recent version (whether local or remote) prevails. This powerful n8n node logic ensures your automation processes are always versioned.

How it Works


  1. The process is initiated by an n8n trigger, specifically a Schedule Trigger, set to run weekly (every Monday).

  2. The workflow first uses the Set n8n node to define crucial configuration variables: GitHub credentials, the repository name, and the specific folder path where the n8n workflow JSON files are stored.

  3. Two parallel branches start: one uses the internal n8n node to retrieve metadata for all active local n8n workflows, and the other uses the GitHub n8n node to list all existing workflow files in the repository.

  4. Files retrieved from GitHub are then pulled individually and decoded from base64 into proper, usable JSON format.

  5. The central piece is the Compare Datasets n8n node, which compares the list of local n8n workflows (Input A) against the decoded GitHub files (Input B) using the workflow ID as the unique key, splitting the flow into four paths: Only in n8n, Only in GitHub, Different, and Same.

  6. New Local Workflow (Only in n8n): Workflows existing only locally are converted to base64 and uploaded to GitHub using the GitHub n8n node, creating a new file.

  7. New Remote Workflow (Only in GitHub): Workflows existing only on GitHub are imported into the n8n instance using the specialized n8n node operation: Create workflow.

  8. Version Conflict (Different): An If n8n node checks the updatedAt timestamp. If the GitHub version is newer, the GitHub version is used to update the local n8n workflow via the Update workflow n8n node. If the local n8n workflow is newer, it is prepared, encoded, and uploaded to overwrite the file on GitHub, ensuring the latest changes are saved. This powerful n8n node comparison capability is key to maintaining synchronization.

Installation Guide


  1. Import the n8n workflow: Copy the provided JSON and import it directly into your n8n instance.

  2. GitHub Credentials: You must configure a GitHub credential that has read and write access to the target repository.

  3. Set GitHub Details n8n node: Open the "Set GitHub Details" n8n node and populate the following required values:

githubaccountname: Your GitHub username or organization name.
githubreponame: The name of the repository dedicated to storing the n8n templates.
* repoworkflowspath: The directory path within the repository where the workflows reside (e.g., workflows/ or n8n_backups/).

  1. n8n Credentials: Ensure you have configured an active n8n API credential that allows the workflow to interact with the local n8n instance (listing, creating, and updating workflows).

  2. Activation: Once credentials and settings are applied, activate the n8n trigger to begin the scheduled sync.

Node Details

Schedule Trigger (n8n trigger): The primary n8n trigger that runs the entire synchronization process on a weekly schedule.
Set GitHub Details (Set n8n node): Used to inject global variables (repository path, account name) needed by subsequent GitHub n8n node operations.
n8n (n8n node): Used in three key ways: 1) Listing all active n8n workflows. 2) Creating new workflows found only on GitHub. 3) Updating existing workflows in n8n if the GitHub version is newer.
GitHub (n8n node): Handles file operations on the repository, including listing contents, fetching individual files, uploading new workflow files, and editing existing files.
Compare Datasets (n8n node): The core decision-making n8n node. It compares local and remote workflow datasets based on ID to identify new, deleted, or differing n8n templates.
If n8n before GitHub (If n8n node): Executes the conflict resolution logic, determining which version of the n8n workflow is superior by comparing timestamps.


  • Convert to File / Extract From File (n8n nodes): Essential for preparing the n8n workflow JSON data (e.g., when a local workflow is newer) by converting it to binary and encoding it into base64 for the GitHub API upload.

Related n8n Workflows

Free

Nodes: 11 Nodes
Updated: December 26 2025
View all
Created by
Wikus Bergh
Wikus Bergh

Software/ML engineer - happily ambling on the path of learning

Featured*