Code Storage now has a first-class merge API for moving changes between branches without cloning a repository or shelling out to Git.
You can merge a source branch into a target branch with regular merge commits, fast-forward-only
updates, or fast-forward-preferred behavior. Source and target branches can also live independently
in the default or ephemeral namespace, which makes it straightforward to promote agent work from an
ephemeral branch into main.
const result = await repo.merge({
sourceBranch: 'feature/preview',
sourceIsEphemeral: true,
targetBranch: 'main',
strategy: 'merge',
expectedTargetSha: currentMainSha,
commitMessage: 'Merge feature/preview',
author: { name: 'Merge Bot', email: 'merge@example.com' },
});result = await repo.merge(
source_branch="feature/preview",
source_is_ephemeral=True,
target_branch="main",
strategy="merge",
expected_target_sha=current_main_sha,
commit_message="Merge feature/preview",
author={"name": "Merge Bot", "email": "merge@example.com"},
)result, err := repo.Merge(ctx, storage.MergeOptions{
SourceBranch: "feature/preview",
SourceIsEphemeral: true,
TargetBranch: "main",
Strategy: storage.MergeStrategyMerge,
ExpectedTargetSHA: currentMainSHA,
CommitMessage: "Merge feature/preview",
Author: &storage.CommitSignature{Name: "Merge Bot", Email: "merge@example.com"},
})The response reports whether the operation created a merge commit, fast-forwarded the target, or was a no-op because the source was already merged. It also includes source and target commit metadata, the merge base when available, and the number of commits promoted onto the target branch.
Merge conflicts return a structured API error while preserving backend fields such as
conflict_paths and merge_base_sha, so callers can show actionable conflict details without
parsing Git output.