Skip to main content

Keep branches up to date with branch merging

Classic apps

You're viewing documentation for classic apps, which use Retool's original app editor. The new app builder is the recommended way to build apps and where Retool focuses new development.

From within the IDE of your classic app, module, workflow, or query, you can use branch merging to integrate changes from your default branch and resolve merge conflicts. While it's also possible to resolve conflicts through your source control provider's UI or the Git CLI, Retool recommends using the in-product branch merging, as it automatically checks for ToolScript validity.

Branch merging in Retool uses the git merge strategy. Read more in the git documentation.

note

Enable branch merging by navigating to Settings > Beta, and toggle on Enable branch merging.

Integrate changes from default branch

Branch merging is enabled when you are developing on a feature branch and have made a commit. When you're ready to update your branch, click the Merge main into <BranchName> button. Retool handles each of the following three scenarios:

  • Your branch is already up to date, and there are no changes to merge.
  • Your branch is out of date, and there are no conflicts between the default branch and your feature branch. Click Commit merge to update your branch.
  • Your branch is out of date, and the changes on the default branch conflict with those on your feature branch. View and resolve the merge conflict from within the IDE. Retool checks that the updated Toolscript is valid. Click Commit merge to update your branch. Refer to Toolscript-specific resolution strategies.

Toolscript-specific resolution strategies

note

Toolscript is available to cloud instances and self-hosted instances on versions 3.6.0 and later. See the migration guide to learn how to migrate your apps from YAML to Toolscript.

If your branch has conflicts with the default branch, you may need to edit Toolscript files. It is important to understand how Toolscript files are structured to resolve merge conflicts correctly. Malformed Toolscript files can result in failed Source Control deployments and prevent builders from pushing new commits.

Metadata files are located in app/.metadata.json. They hold metadata about the application, such as the Retool version the app was edited on and app-level settings.

If the conflict is in the version field, you should keep the later version number.

Most other fields in this file reference app-level settings. If two builders modify the same setting, keep only one valid change in the final commit. If two builders toggle different settings, it is safe to keep both settings.

Merge conflict prevention strategies

The development processes you use can help prevent merge conflicts from arising in the first place.

Keep branches short-lived

Keep a branch open for a week or less, and merge as soon as review completes. The longer a branch stays open, the more changes land on main behind it, and the more likely a conflict becomes.

Add test deployments to your CI pipeline

A test deployment validates a change against your Retool instance before it merges. Adding it as a required check in GitHub or your SCM provider stops invalid changes from reaching main.

Divide work so builders don't collide

Two builders editing the same app on separate branches will conflict. Two builders editing different parts of it usually won't.

  • Use modules to encapsulate work. A module is an isolated part of an app that one person can develop without affecting others. Before starting a complex app, plan which pieces should be modules.
  • Split responsibilities by file area. Assigning one builder the executable pieces such as queries and transformers and another the visual pieces such as headers, titles, and images keeps them in different directories, since the former affects lib/ and the latter mostly src/.