通过仪表板分支
Create, manage, review, and merge branches directly in the dashboard
你可以直接通过仪表板创建、管理、查看和合并 Supabase 分支。这对于快速测试、原型设计或你更喜欢无代码操作的时候很有用。如果需要,你还可以在以后将 Supabase 分支连接到 GitHub 分支。
🌐 You can create, manage, review, and merge Supabase branches directly via the dashboard. This is useful for quick testing, prototyping, or when you prefer to work in a no-code way. You can also connect a Supabase branch to a GitHub branch at a later time if needed.
公开测试版
通过仪表板进行分支管理目前处于公开测试阶段。功能和特性可能会有所变化。
🌐 Branch management via the dashboard is currently in public alpha. Features and functionality may change.
分支是如何工作的 #
🌐 How Branching works
你可以直接在 Supabase 仪表板上做以下操作:
🌐 You can do the following directly from the Supabase dashboard:
- 创建预览分支
- 对你的公共模式或边缘函数进行修改
- 准备好后把这些更改合并回生产环境
- 从生产环境拉取更新
通过仪表板启用分支管理 #
🌐 Enable branch management via the dashboard
此功能目前处于测试阶段,需要选择加入。要加入,你必须启用功能预览:
🌐 This functionality is currently in beta and requires opting in. To opt in you must enable the feature preview:
- 点击右上角的用户图标打开用户菜单。
- 选择 通过仪表板分支。
- 点击 启用功能。
创建分支 #
🌐 Creating a branch
在没有 GitHub 集成的情况下使用仪表板分支时,分支下拉菜单在每个项目上都会显示 main / PRODUCTION,但在全新项目中,生产分支还没有注册。第一次点击“创建分支”会在后台填充这一行——从技术上讲,这会在项目中启用分支功能——并且需要拥有者/管理员权限。完成这一步之后,任何拥有开发者角色的人都可以创建、更新和删除预览分支。
🌐 When using dashboard branching without a GitHub integration, the branch dropdown displays main / PRODUCTION on every project, but on a brand-new project the production branch hasn't been registered yet. The first "Create branch" click populates this row behind the scenes — technically enabling branching on the project — and requires Owner/Administrator access. After that one-time step, anyone with the Developer role can create, update, and delete preview branches.
一旦你启用了这个功能,你就可以创建一个新分支了:
🌐 Once you've enabled the feature, you can create a new branch:
- 点击顶部菜单栏中分支名称旁边的箭头。(顶部菜单栏的格式是
YOUR_ORGANIZATION / YOUR_PROJECT / CURRENT_BRANCH_NAME。) - 点击
Create branch。
修改分支 #
🌐 Making changes to a branch
使用顶部栏的分支选择器切换到你的分支。你所做的任何更改(包括在 SQL 编辑器中运行的 SQL、表格编辑器的更改以及配置更改)现在都会针对当前选中的分支生效。
🌐 Use the branch selector in the top bar to change to your branch. Any changes you make (including SQL run in the SQL editor, table editor changes, and configuration changes) are now made against the currently selected branch.
你也可以使用分支的 API 密钥和连接字符串,通过你自己的代码或 SQL 客户端对分支进行修改。
🌐 You can also use the branch's API keys and connection strings to run changes against the branch from your own code or SQL client.
创建合并请求 #
🌐 Creating a merge request
要将分支的更改审查并合并回你的生产分支,你必须先创建一个合并请求。有两种方法可以做到这一点。
🌐 To review and merge changes from a branch back into your production branch, you must first create a merge request. There are two ways to do this.
第一步是点击位于顶部菜单中分支选择器旁边的合并请求按钮。这样会创建一个合并请求,并把你带到合并页面,在那里你可以查看并合并任何更改。
🌐 The first is to click the merge request button next to the branch selector that's located in the top menu. This will create the merge request and redirect you to the merge page where you can review and merge any changes.
第二步是在分支选择器中点击管理分支,然后在左侧导航栏中点击合并请求。从这里你可以查看所有未完成的合并请求,也可以创建新的合并请求。
🌐 The second is to click on manage branches from within the branch selector, then in the left hand navigation you can click on merge requests. From here you can view all open merge requests and create new ones.
把生产环境的更改拉到分支上 #
🌐 Pulling changes from production into a branch
在审查合并请求时,你可能会在页面顶部看到一条提示,要求你更新分支。当你的预览分支与生产分支发生偏移时,就会出现这种情况。在创建预览分支之后,可能会有公共 schema 或边缘函数的更改。点击更新分支会尝试将这些更改拉入,但请注意,这样做会替换你现有的边缘函数。在预览分支上创建的任何新的边缘函数将保持不变。
🌐 When reviewing a merge request you may see a notice at the top of the page asking you to update your branch. This appears when your preview branch has drifted from your production branch. There may be public schema or edge function changes that have been made after your preview branch was created. Clicking update branch will attempt to pull in these changes, but be aware that by doing this your existing edge functions will be replaced. Any new edge functions created on the preview branch will remain untouched.
限制 #
🌐 Limitations
在决定不使用 git 进行分支之前,你应该意识到一些限制。
🌐 There are a few limitations you should be aware of before deciding to use branching without git.
- 通过仪表板创建的自定义角色在创建分支时不会被捕获
- 分支只能合并到主分支;预览分支之间不支持合并
- 如果你的分支过时了,你可以从主分支拉取最新的更改,但请记住,所有功能都会被覆盖
- 在主分支上删除功能必须手动进行
- 迁移冲突必须在预览分支上手动解决
- 如果你在 main 上运行了迁移,新分支将会从现有迁移创建,而不是完整的架构导出