Skip to content

Git 和 n8n(Git and n8n)#

n8n 使用 Git 提供源代码控制。要使用此功能,了解一些基本的 Git 概念会很有帮助。n8n 并没有实现所有 Git 功能:你不应该将 n8n 的源代码控制视为完整的版本控制。

🌐 n8n uses Git to provide source control. To use this feature, it helps to have some knowledge of basic Git concepts. n8n doesn't implement all Git functionality: you shouldn't view n8n's source control as full version control.

刚接触 Git 和源代码管理?

如果你是 Git 新手,不要慌。使用 n8n 不需要你掌握 Git。本文件解释了你所需的概念。不过,要设置源代码控制,你确实需要一些 Git 知识,因为这涉及到在你的 Git 提供商中操作。

熟悉 Git 和源代码管理吗?

如果你熟悉 Git,不要指望行为完全一致。特别要注意,n8n 中的源代码控制不支持拉取请求式的审查和合并流程,除非你在 n8n 外部的 Git 提供平台上进行此操作。

本页面介绍了 n8n 中使用的 Git 概念和术语,但并未涵盖设置和管理仓库所需的所有内容。进行设置的人应对 Git 及其 Git 托管服务有一定了解。

🌐 This page introduces the Git concepts and terminology used in n8n. It doesn't cover everything you need to set up and manage a repository. The person doing the Setup should have some familiarity with Git and with their Git hosting provider.

这是一个简短的介绍

Git 是一个复杂的主题。本节简要介绍在 n8n 中使用环境时需要了解的关键术语。如果你想深入学习 Git,请参考 GitHub | Git 和 GitHub 学习资源

Git 概述(Git overview)#

Git 是一个用于管理、跟踪和协作处理文档多个版本的工具。它是广泛使用的平台,如 GitHubGitLab 的基础。

分支:项目的多个副本(Branches: Multiple copies of a project)#

Git 使用分支来维护文档的多个副本。每个分支都有自己的版本。一种常见的模式是有一个主分支,然后每个想要为项目做出贡献的人都会在自己的分支(副本)上工作。当他们完成工作后,他们的分支会被合并回主分支。

🌐 Git uses branches to maintain multiple copies of a document alongside each other. Every branch has its own version. A common pattern is to have a main branch, and then everyone who wants to contribute to the project works on their own branch (copy). When they finish their work, their branch is merged back into the main branch.

Diagram

本地和远程:在你的机器和 Git 提供商之间移动工作(Local and remote: Moving work between your machine and a Git provider)#

使用 Git 的一个常见模式是先在自己的电脑上安装 Git,然后使用像 GitHub 这样的 Git 提供商在云端进行 Git 操作。实际上,你在 GitHub 上有一个 Git 仓库(项目),并在本地机器上操作其副本。

🌐 A common pattern when using Git is to install Git on your own computer, and use a Git provider such as GitHub to work with Git in the cloud. In effect, you have a Git repository (project) on GitHub, and work with copies of it on your local machine.

n8n 在源代码管理中使用这种模式:你将在你的 n8n 实例上处理工作流,但会将它们发送到你的 Git 提供商进行存储。

🌐 n8n uses this pattern for source control: you'll work with your workflows on your n8n instance, but send them to your Git provider to store them.

推送、拉取和提交(Push, pull, and commit)#

n8n 使用三个关键的 Git 进程:

🌐 n8n uses three key Git processes:

  • 推送:将工作从你的实例发送到 Git。这会将你的工作流和标签的副本,以及凭证和变量存根,保存到 Git。你可以选择要保存的工作流。
  • 拉取:从 Git 获取工作流、标签和变量,并将其加载到 n8n 中。你需要填写刷新项目中包含的任何凭据或变量占位符。

    拉取会覆盖你的工作

    如果你在 n8n 中对工作流进行了更改,必须在拉取之前将更改推送到 Git。当你拉取时,如果这些更改未存储在 Git 中,它会覆盖你所做的任何更改。

  • 提交:在 n8n 中,提交是将工作推送到 Git 的一次单独操作。在 n8n 中,提交和推送是同时发生的。

有关 n8n 如何与 Git 交互的详细信息,请参阅 推送和拉取

🌐 Refer to Push and pull for detailed information about how n8n interacts with Git.