Environments give your team a safe place to build and test workflows before anything reaches the live one. This post starts with one bad Friday, then adds three fixes, one layer at a time: separate environments, Git version control, and a controlled path for promoting and rolling back changes. (A hypothetical story, but you may recognize it.) It's 4:47 on a Friday. Priya from sales ops asks for one last thing before the weekend: leads from the new EMEA territory should go to the EMEA reps, not the general queue. Sam, who owns automation, opens Lead Routing in the one n8n instance the whole company shares, adds a rule to the Switch node, and sends two real leads through the workflow to check it, because that's the only test data around. The execution is green. Sam saves, publishes, and signs off for the weekend. On Monday at 9:15, the EMEA reps ask why their pipeline is empty. Over the weekend, 63 EMEA leads were assigned to a rep who left in October. Sam opens Lead Routing to roll the change back and realizes there's nothing to roll back to. In this post we will cover: The incident. What went wrong, and why nobody could undo it. Fix 1. Separate environments, so the change is built and tested away from production. Fix 2. Git, so every change has an author, a message, and a history. Fix 3. Promoting and rolling back, so changes reach production on purpose. What actually happened By lunchtime, the story comes together. It has less to do with the change itself than with where the change was made. One instance did three jobs. Building, testing, and running live leads all happened in the same place. Test data was real data. With no safe copy of the workflow, Sam tested against live leads. The new rule had a wrong rep. It pointed at a rep ID copied from an old spreadsheet, and nothing in the execution flagged it. There was no record of the previous version. Two other people had edited Lead Routing that week, and nobody could say what the Switch node looked like before. There was no way back. Fixing it meant rebuilding the old rules from memory while the leads waited. The problem wasn't a careless builder. It was a team that grew into one n8n instance doing the work of three, with nobody deciding where changes should happen first. Each of the next three fixes closes a different gap, starting with where the change gets built. Fix 1: build and test away from production The gap: Sam had nowhere to try the change except the live workflow. The fix is a place to make mistakes where they don't cost anything, starting with two n8n instances instead of one. Think of a restaurant. The chef tries a new dish in the test kitchen, tastes it, adjusts it, and only then puts it on the menu. Nobody tests a new recipe on diners in the middle of service. An environment is that test kitchen for your workflows. The analogy stops at one point: in n8n, the kitchens are separate instances, not rooms inside one. In n8n, an environment has two parts. The n8n instance is where you build and run workflows. The Git branch stores copies of the workflows, along with tags and stubs for variables and credentials. A common starting point is two environments: development to do the work, and production as the live one. Now run Friday again. Sam builds the EMEA rule in the development instance and sends five test leads through it. The development instance has its own credentials, so those leads go to a sandbox CRM account, not the real one. The sandbox shows every EMEA lead assigned to a rep who left in October. Sam fixes the ID in five minutes, and production never sees the mistake. There's one more control worth setting on the production instance. The settings page shown next is where you link an instance to a branch and mark it as protected. With Protected instance selected, users can't edit source-controlled resources in that instance. Changes have to arrive from Git, so the live workflow always matches what's on the branch. Separate environments stop a mistake from reaching production. They don't tell you who changed what, or let anyone return to last week's version. That's the job of the next layer, Git. Fix 2: Git keeps a record of every change Two environments still leave a question open: who changed Lead Routing, when, and why? The fix is Git, the version control tool that n8n's environments are built on. Picture a contract that five people edit by email, each saving their own copy as "final_v3_REAL.docx". When something goes wrong, nobody can say which copy is the right one. Git replaces those copies with one shared history, where every change is saved with its author and a short message. n8n uses this pattern: you work on your instance, and Git stores the copies. One limit to keep in mind is that n8n's source control isn't full version control, and review and merge happen in your Git provider, not in n8n. Now rewind to the week before Friday. Each time someone finishes a change to Lead Routing in development, they push it to Git. n8n sends the workflows you pick, plus tags and credential and variable stubs, and each push is a commit with a message. On Friday, Sam pushes the EMEA rule with a clear message, and the history already holds the two earlier edits. To push work from the development instance, follow these steps: Select Push in the main menu. In the Commit and push changes modal, select the workflows to include. You can filter by status and search for items. Enter a commit message that describes the change in one sentence. Select Commit and Push. n8n sends the work to Git and shows a success message. The modal in step 2 is where you choose what goes into each commit, as shown next. This is also what makes teamwork safer. Because every contributor's work lands in Git as its own commit, you can see who changed what, and work is merged on purpose in your Git provider, not overwritten by accident. A history is useful on its own, but it matters most when it controls how work moves between environments. The last fix covers that path. Fix 3: promote on purpose, roll back on demand So far, Sam's change stays safe in development and has a history. The last question is how it reaches production, and how you undo it if it still goes wrong. Think of a book going to print. The author finishes a draft, an editor reads it, and only then does it go to the printer. Promoting a workflow works the same way: the work doesn't move to production because someone clicked a button in a hurry, but because someone approved it. In n8n, you decide how formal that approval is by choosing a branch pattern. The multi-branch pattern fits the Friday story best. Sam's change sits on the development branch, a teammate reviews the pull request into production, and the merge is the moment the team decides the change is ready. Then someone selects Pull in the production instance. If you'd rather not log in to production to pull, a GitHub Action can call the n8n API to pull every time the production branch changes. Now the rollback. Suppose the bad rule had reached production anyway. Because production only ever receives what's on its branch, the previous version is sitting in Git. Revert the merge in your Git provider, select Pull in production, and the earlier rules come back, with no rebuilding from memory. The path from development to production has one gate, the merged pull request, as shown next. The three layers now fit together, and the next section puts them side by side. The same Friday, with all three fixes Here's the same Friday with all three fixes in place. It's 4:47 again, and Priya asks for the same EMEA rule. Sam builds the rule in development and sends five test leads through a sandbox CRM. The wrong rep shows up on the first one, and Sam fixes it before pushing with the message "Add EMEA rule to Lead Routing". A teammate reviews the pull request into production on Monday morning, merges it, and selects Pull. Production is protected, so nobody can edit it by hand in between. By 9:15, the EMEA reps have leads, and nobody has opened Lead Routing to roll anything back. The table sums up what changed, and which fix is responsible for each change. The three layers overlap on purpose. Any one of them would have changed that Monday. Together, you'd have to get all three wrong at once. That's a lot of structure, so the next section is about how much of it you need today. When is it worth adding environments? Environments add moving parts, so it's fair to ask when they're worth it. The answer depends on who relies on your workflows. If it's you and a weekend experiment, one instance is fine. The moment other people depend on a workflow, someone has to decide where changes get built, tested, and approved. It's much easier to set that up before the Friday afternoon tweak than after the Monday morning clean-up. A sensible first step is two environments and one branch pattern, then adding a protected production instance and a review step as the team grows. Source control and environments are available on Business and Enterprise plans. If you're ready to start, the next section walks through a first setup. You can set up a first pair of environments with a development instance, a production instance, and the multi-branch pattern. The steps use GitHub, and the process is similar for other Git providers. An instance owner or admin needs to configure source control. To set up your environments, follow these steps: Create a private repository in your Git provider, then add development and production branches. Create two n8n instances, one for development and one for production. In each instance, go to Settings > Environments and add your repository URL and authentication details. Select Connect, then choose the matching branch under Instance settings. In production, select Protected instance. In both instances, select Save settings. In development, select Push, choose your workflows, and enter a commit message. Merge development into production with a pull request, then select Pull in the production instance. The docs cover each part in more detail: Environments in n8n. How instances and Git branches fit together. Git and n8n. The Git concepts you need, and where n8n's source control differs from full version control. Set up source control and environments. Prerequisites, authentication, and the instance settings. Tutorial: Create environments with source control. An end-to-end walkthrough of both branch patterns, including the GitHub Action for automated pulls. Start with the tutorial, and ask whoever manages your Git provider to help with the repository and deploy key. Share with us n8n users come from a wide range of backgrounds, experience levels, and interests. We have been looking to highlight different users and their projects in our blog posts. If you're working with n8n and would like to inspire the community, contact us 💌
AI NEWS JOURNAL
n8n 官方博客AI NEWS / JOURNAL
Why you need environments: how one tweak can have consequences
Environments give your team a safe place to build and test workflows before anything reaches the live one. This post starts with one bad Friday, then adds three fixes, one layer at a time: separate environments, Git version control, and a controlled path for promoting and rolling back changes.(A