Branching(分支(Branching))¶
Version control tools are commonly used in software to allow groups of developers to work together as effectively as possible. The use of version control, along with good development practices, allows engineers to build features quickly while maintaining confidence that the changes they introduce are of high quality.
Branching in Code Workbook provides a version control experience tailored to data transformation, enabling teams to operate on logic and data simultaneously in a Workbook.
Branches¶
By default, Workbooks are created with a single branch with the same name as the default branch across all of Foundry. Typically, this branch is called master. You can use the branch menu to browse and select a branch, create new branches, and change branch settings.

Creating branches¶
:::callout{theme="warning"} By default, Code Workbook allows you to create at most 100 branches. If your workbook had over 100 branches before the limit was put in place, all your existing branches will remain, but you will not be able to create additional branches until the number of branches in your workbook is reduced to less than 100. :::
Type the name of your new branch in the branch menu, then click Create branch or use the Enter key to create your new branch. A new branch will be created in the Workbook with the current branch as its parent.
When you create a branch, Code Workbook keeps track of the state of each dataset at the time of branch creation. Any transforms you run on your new branch will use this stored state to load data. This means that changes on the parent branch will not break new branches you have created.

When you run transforms on a branch, Code Workbook creates branches on the associated Foundry datasets so that the results of your logic changes are stored in isolation from other branches. After writing to Foundry has completed, click Open dataset in the Output panel to view your result dataset on your branch.
Deleting branches¶
To delete a branch, navigate to the branch and click the trash can icon in the top-right of the branch menu. Deleting a branch that still has child branches based on it will re-parent those branches. For example, if you have three branches master -> develop -> feature, deleting develop will result in feature’s parent becoming the master branch.
Merging branches¶
Once you're done working on your branch, you can merge it back into the parent branch to incorporate your work. Learn more about merges.
Branch settings¶
To edit branch settings, navigate to a branch and click the gear icon in the top-right of the branch menu. In most Workbooks, you will only need to edit branch settings on the masterbranch.
Branch settings can be used to customize the process for making changes to a branch. Currently, branch settings allow you to set a few options:
- Is the branch protected? If a branch is protected, nobody can make edits to the branch directly. Instead, all changes must be merged in through another branch. Note that if a branch is protected, merging into it requires Owner permissions on the Workbook.
- Does the branch allow running? If a branch is protected and this setting is turned off, datasets on this branch must be materialized using Foundry builds. This ensures that nobody can initiate an interactive run that prevents builds from succeeding.
中文翻译¶
分支(Branching)¶
版本控制(version control)工具在软件开发领域被广泛使用,旨在帮助开发者团队实现最高效的协作。结合良好的开发实践使用版本控制,工程师既能快速迭代功能,也能保证自己提交的变更质量达标。
代码工作簿(Code Workbook)中的分支(Branching)功能提供了专为数据转换(data transformation)场景定制的版本控制体验,支持团队在同一个工作簿(Workbook)中同时处理逻辑与数据。
分支(Branches)¶
默认情况下,新建工作簿仅包含一个分支,其名称与整个Foundry平台的默认分支名称一致,通常为master。你可以通过分支菜单浏览、选择分支,创建新分支,或是修改分支设置。

创建分支¶
:::callout{theme="warning"} 默认情况下,代码工作簿最多支持创建100个分支。如果在该限制生效前你的工作簿分支数已经超过100,所有已有分支都会被保留,但你无法再创建新分支,直到工作簿内的分支数量减少到100以下。 :::
在分支菜单中输入新分支的名称,点击创建分支(Create branch)或者按回车键即可完成创建,新分支会以当前分支作为父分支。
创建分支时,代码工作簿会记录分支创建时刻每个数据集(dataset)的状态。你在新分支上运行的所有转换(transform)操作都会基于这个存储的状态加载数据,这意味着父分支上的变更不会破坏你已创建的新分支。

你在某个分支上运行转换时,代码工作簿会为关联的Foundry数据集创建对应分支,这样你修改逻辑得到的运行结果会和其他分支的内容隔离存储。写入Foundry的操作完成后,点击输出面板中的打开数据集(Open dataset)即可查看你当前分支下的结果数据集。
删除分支¶
如需删除分支,先切换到对应分支,点击分支菜单右上角的垃圾桶图标即可。如果被删除的分支还有基于它创建的子分支,这些子分支会被重新关联到上一级父分支。例如,你有三个分支的层级为master -> develop -> feature,删除develop后,feature的父分支会变为master分支。
合并分支¶
你在分支上的工作完成后,可以将其合并(merge)回父分支,从而提交你的工作成果。了解更多关于合并的内容。
分支设置¶
如需编辑分支设置,先切换到对应分支,点击分支菜单右上角的齿轮图标即可。大多数场景下,你仅需要修改master分支的设置。
分支设置可用于自定义向分支提交变更的流程,目前支持配置以下选项: * 分支是否受保护?如果分支被设为受保护,任何人都无法直接编辑该分支,所有变更必须通过其他分支合并进入。请注意,向受保护分支执行合并操作需要你拥有该工作簿的所有者(Owner)权限。 * 分支是否允许运行?如果分支为受保护分支且关闭了该设置,该分支上的数据集必须通过Foundry构建(Foundry builds)来物化(materialize)。这可以避免任何人启动交互式运行,导致构建任务执行失败。