> ## Documentation Index
> Fetch the complete documentation index at: https://code.storage/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# repo.previewMerge()

> Preview whether a source branch can merge into a target branch without creating commits or updating refs.

> [!WARNING]
>
> This page documents the earlier Code Storage SDKs: `@pierre/storage`, `pierre-storage`, and
> `code-storage-go`. New code uses the [Pierre SDK](https://code.storage/docs/sdks.md). To move code to the new SDK, use the
> [`pierre-migrate`
> skill](https://github.com/pierrecomputer/skills/tree/main/skills/pierre-migrate).

```typescript TypeScript theme={null} theme={"theme":{"light":"github-light","dark":"min-dark"}}
const preview = await repo.previewMerge({
  sourceBranch: 'feature/preview',
  targetBranch: 'main',
  includeContent: true, // optional bounded conflict blob content
});

console.log(preview.status); // "clean" or "conflicted"
console.log(preview.result); // "merge_commit", "fast_forward", or "no_op"

if (preview.status === 'conflicted') {
  console.log(preview.conflictPaths);
  console.log(preview.filteredConflicts);

  for (const conflict of preview.conflicts) {
    console.log(conflict.path);
    console.log(conflict.result.content);
  }
}
```

```python Python theme={null} theme={"theme":{"light":"github-light","dark":"min-dark"}}
preview = await repo.preview_merge(
    source_branch="feature/preview",
    target_branch="main",
    include_content=True,  # optional bounded conflict blob content
)

print(preview["status"])  # "clean" or "conflicted"
print(preview["result"])  # "merge_commit", "fast_forward", or "no_op"

if preview["status"] == "conflicted":
    print(preview["conflict_paths"])
    print(preview["filtered_conflicts"])

    for conflict in preview["conflicts"]:
        print(conflict["path"])
        print(conflict["result"].get("content"))
```

```go Go theme={null} theme={"theme":{"light":"github-light","dark":"min-dark"}}
includeContent := true
preview, err := repo.PreviewMerge(context.Background(), storage.PreviewMergeOptions{
	SourceBranch:   "feature/preview",
	TargetBranch:   "main",
	IncludeContent: &includeContent,
})
if err != nil {
	log.Fatal(err)
}

fmt.Println(preview.Status) // "clean" or "conflicted"
fmt.Println(preview.Result) // "merge_commit", "fast_forward", or "no_op"

if preview.Status == storage.PreviewMergeStatusConflicted {
	fmt.Println(preview.ConflictPaths)
	fmt.Println(preview.FilteredConflicts)

	for _, conflict := range preview.Conflicts {
		fmt.Println(conflict.Path)
		fmt.Println(conflict.Result.Content)
	}
}
```

`previewMerge()` is read-only. It checks the merge result with a `git:read` scoped request and does
not create commits or update refs.

Pass `includeContent` when you want inline conflict blob content. The response still includes
`conflictPaths` when content is omitted or filtered.

## Options

**sourceBranch** `string` *required*

Source branch name to merge from.

**targetBranch** `string` *required*

Target branch name to merge into.

**includeContent** `boolean`

Include bounded conflict blob content in `conflicts` when the preview is conflicted. Python:
`include_content`. Go: `IncludeContent` as `*bool`.

**ttl** `number`

Token TTL for this invocation in seconds. In Go, use `TTL` as a `time.Duration`.

## Response

Field names below use TypeScript casing. Python returns snake\_case keys and Go returns exported
struct fields.

**status** `string`

Preview status: `clean` or `conflicted`.

**result** `string`

Merge outcome if applied: `merge_commit`, `fast_forward`, or `no_op`.

**sourceBranch** `string`

Resolved source branch name.

**targetBranch** `string`

Resolved target branch name.

**sourceTipSha** `string`

Source branch tip SHA used for the preview.

**targetTipSha** `string`

Target branch tip SHA used for the preview.

**mergeBaseSha** `string`

Merge base SHA when the backend reports one.

**conflictPaths** `string[]`

Paths that would conflict if the merge were applied.

**conflicts** `object[]`

Inline conflict details for each returned path. Each item has `path`, `result`, `base`, `ours`,
and `theirs` fields. `ours` is the target branch stage and `theirs` is the source branch stage.
Blob fields include `oid`, `content`, `truncated`, and `binary`.

**filteredConflicts** `object[]`

Conflicted paths whose inline content was omitted. Each item has `path` and `reason`, such as
`max_conflict_files_exceeded`.

## Notes

* `conflicts` is empty when `includeContent` is omitted or set to `false`.
* `filteredConflicts` tells you which conflicted files were left out of the inline preview and why.
* Use [`merge()`](https://code.storage/docs/sdk/repos/merge) after a clean preview when you are ready to update the target
  branch.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.