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

# Compare Branches

> Compare two branches to preview a potential pull request.

Reports whether the source branch can be fast-forward merged into the
target, how many commits the source is ahead/behind, and whether any
conflicts would arise. Typically called by the UI before opening a PR
so the author can see what the merge would do.

Branches are identified in the URL as `{source_branch}..{target_branch}`,
matching `git diff` syntax.



## OpenAPI

````yaml get /orgs/{org_id}/nodes/{node_id}/branches/diff/{source_branch}..{target_branch}
openapi: 3.1.0
info:
  title: Flow API
  description: Content-addressing backend with Git-like versioning
  version: 1.0.0
servers:
  - url: https://api.yertle.com
    description: Production
security: []
paths:
  /orgs/{org_id}/nodes/{node_id}/branches/diff/{source_branch}..{target_branch}:
    get:
      tags:
        - branches
      summary: Compare Branches
      description: >-
        Compare two branches to preview a potential pull request.


        Reports whether the source branch can be fast-forward merged into the

        target, how many commits the source is ahead/behind, and whether any

        conflicts would arise. Typically called by the UI before opening a PR

        so the author can see what the merge would do.


        Branches are identified in the URL as
        `{source_branch}..{target_branch}`,

        matching `git diff` syntax.
      operationId: >-
        compare_branches_orgs__org_id__nodes__node_id__branches_diff__source_branch____target_branch__get
      parameters:
        - name: org_id
          in: path
          required: true
          schema:
            type: string
            title: Org Id
        - name: node_id
          in: path
          required: true
          schema:
            type: string
            title: Node Id
        - name: source_branch
          in: path
          required: true
          schema:
            type: string
            title: Source Branch
        - name: target_branch
          in: path
          required: true
          schema:
            type: string
            title: Target Branch
        - name: authorization
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Authorization
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BranchComparisonResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    BranchComparisonResponse:
      properties:
        source_branch:
          type: string
          title: Source Branch
          description: Source branch name
        target_branch:
          type: string
          title: Target Branch
          description: Target branch name
        source_commit:
          type: string
          title: Source Commit
          description: Source branch HEAD commit
        target_commit:
          type: string
          title: Target Commit
          description: Target branch HEAD commit
        can_merge:
          type: boolean
          title: Can Merge
          description: Whether branches can be merged via fast-forward
        merge_reason:
          anyOf:
            - type: string
            - type: 'null'
          title: Merge Reason
          description: Reason if merge is not possible
        commits_ahead:
          type: integer
          title: Commits Ahead
          description: Number of commits source is ahead of target
        commits_behind:
          type: integer
          title: Commits Behind
          description: Number of commits source is behind target
        has_conflicts:
          type: boolean
          title: Has Conflicts
          description: Whether merge would have conflicts
          default: false
        comparison:
          additionalProperties: true
          type: object
          title: Comparison
          description: Additional comparison data
      type: object
      required:
        - source_branch
        - target_branch
        - source_commit
        - target_commit
        - can_merge
        - commits_ahead
        - commits_behind
      title: BranchComparisonResponse
      description: Response model for branch comparison.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError

````