> ## 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.

# previewMerge()

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

<CodeGroup>
  ```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)
  	}
  }
  ```
</CodeGroup>

`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

<ParamField path="sourceBranch" type="string" required>
  Source branch name to merge from.
</ParamField>

<ParamField path="targetBranch" type="string" required>
  Target branch name to merge into.
</ParamField>

<ParamField path="includeContent" type="boolean">
  Include bounded conflict blob content in `conflicts` when the preview is conflicted. Python: `include_content`. Go: `IncludeContent` as `*bool`.
</ParamField>

<ParamField path="ttl" type="number">
  Token TTL for this invocation in seconds. In Go, use `TTL` as a `time.Duration`.
</ParamField>

## Response

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

<ResponseField name="status" type="string">
  Preview status: `clean` or `conflicted`.
</ResponseField>

<ResponseField name="result" type="string">
  Merge outcome if applied: `merge_commit`, `fast_forward`, or `no_op`.
</ResponseField>

<ResponseField name="sourceBranch" type="string">
  Resolved source branch name.
</ResponseField>

<ResponseField name="targetBranch" type="string">
  Resolved target branch name.
</ResponseField>

<ResponseField name="sourceTipSha" type="string">
  Source branch tip SHA used for the preview.
</ResponseField>

<ResponseField name="targetTipSha" type="string">
  Target branch tip SHA used for the preview.
</ResponseField>

<ResponseField name="mergeBaseSha" type="string">
  Merge base SHA when the backend reports one.
</ResponseField>

<ResponseField name="conflictPaths" type="string[]">
  Paths that would conflict if the merge were applied.
</ResponseField>

<ResponseField name="conflicts" type="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`.
</ResponseField>

<ResponseField name="filteredConflicts" type="object[]">
  Conflicted paths whose inline content was omitted. Each item has `path` and `reason`, such as `max_conflict_files_exceeded`.
</ResponseField>

## 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()`](/reference/sdk/merge) after a clean preview when you are ready to update the target branch.
