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

# Discard branch changes

> <Info>This API is in beta. Endpoints, fields, and behavior may still change, so avoid depending on it in production.</Info>

Throws away a branch's uncommitted changes, so it matches its latest commit again. Committed changes and anything already on GitHub stay. This works on apps imported from GitHub.

Send the branch as `branch_id`, or leave it out for the main branch. The call runs in that branch's environment. If the environment isn't running, the call starts it first, which can take a few minutes. Discarded changes can't be recovered. Discarding when there's nothing to discard returns the current state.

This endpoint is limited to 10 requests per minute per user, shared with Commit branch changes, Revert branch file changes, Open pull request and Update pull request, and reported in the `X-RateLimit-*` headers.

<Note>This endpoint accepts a personal API key or personal access token belonging to a user with editor access to the app. A read-only key is refused, and workspace API keys are not accepted. Send credentials in a header: an `api_key` query parameter is refused.</Note>



## OpenAPI

````yaml /developers/references/app-management/app-management-openapi.json post /api/apps/{app_id}/imported/git/discard
openapi: 3.1.0
info:
  title: Base44 App Management API
  version: 1.0.0
servers:
  - url: https://app.base44.com
security:
  - PersonalAccessTokenAuth: []
paths:
  /api/apps/{app_id}/imported/git/discard:
    post:
      summary: Discard branch changes
      description: >-
        <Info>This API is in beta. Endpoints, fields, and behavior may still
        change, so avoid depending on it in production.</Info>


        Throws away a branch's uncommitted changes, so it matches its latest
        commit again. Committed changes and anything already on GitHub stay.
        This works on apps imported from GitHub.


        Send the branch as `branch_id`, or leave it out for the main branch. The
        call runs in that branch's environment. If the environment isn't
        running, the call starts it first, which can take a few minutes.
        Discarded changes can't be recovered. Discarding when there's nothing to
        discard returns the current state.


        This endpoint is limited to 10 requests per minute per user, shared with
        Commit branch changes, Revert branch file changes, Open pull request and
        Update pull request, and reported in the `X-RateLimit-*` headers.


        <Note>This endpoint accepts a personal API key or personal access token
        belonging to a user with editor access to the app. A read-only key is
        refused, and workspace API keys are not accepted. Send credentials in a
        header: an `api_key` query parameter is refused.</Note>
      operationId: discard_changes_api_apps__app_id__imported_git_discard_post
      parameters:
        - name: app_id
          in: path
          required: true
          schema:
            type: string
            description: ID of the app.
            title: App Id
          description: ID of the app.
          example: 6820f3a4e7b91d003c45a1f2
        - name: branch_id
          in: query
          required: false
          schema:
            type: string
            description: >-
              ID of the branch to work on, as returned by [List
              branches](/api-reference/list-branches). Omit it to work on the
              app's main branch.
            title: Branch Id
          description: >-
            ID of the branch to work on, as returned by [List
            branches](/api-reference/list-branches). Omit it to work on the
            app's main branch.
          example: 68f1a2b3c4d5e6f708192a3b
      responses:
        '200':
          description: The branch's git state after discarding.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BranchGitStatus'
              example:
                current_branch: feature/checkout
                default_branch: main
                base_branch: main
                head: 9fceb02d0ae598e95dc970b74767f19372d61af8
                head_committed_at: '2026-10-28T09:15:00Z'
                dirty: false
                dirty_files: []
                ahead: 1
                behind: 0
                merge_in_progress: false
        '401':
          description: >-
            `unauthenticated`: Missing or invalid credentials, or credentials
            sent as an `api_key` query parameter.
          content:
            application/json:
              examples:
                unauthenticated:
                  summary: unauthenticated
                  value:
                    error:
                      code: unauthenticated
                      message: 'Use Authorization: Bearer credentials.'
                      details: {}
              schema:
                $ref: '#/components/schemas/StandardErrorEnvelope'
        '403':
          description: >-
            `forbidden`: You don't have editor access to this app, your API key
            is read-only, or you used a workspace API key.
          content:
            application/json:
              examples:
                forbidden:
                  summary: forbidden
                  value:
                    error:
                      code: forbidden
                      message: You don't have editor access to this app.
                      details: {}
              schema:
                $ref: '#/components/schemas/StandardErrorEnvelope'
        '404':
          description: >-
            `not_found`: The app or `branch_id` doesn't exist, or the app isn't
            imported from GitHub.
          content:
            application/json:
              examples:
                not_found:
                  summary: not_found
                  value:
                    error:
                      code: not_found
                      message: Branch not found
                      details: {}
              schema:
                $ref: '#/components/schemas/StandardErrorEnvelope'
        '409':
          description: >-
            `git_discard_failed`: The changes couldn't be discarded; retry.
            `git_status_failed`: The state couldn't be read; retry shortly.
            `app_processing`: The AI is working on the app; wait for it to
            finish. `git_busy`: Another git operation is running on the branch;
            retry shortly. `branch_scope_read_only`: The branch is merged or
            closed. `branch_sync_in_progress`: A conflict resolution is waiting
            on the branch. `branch_protected`: Main is protected; work on a
            branch. `sandbox_unavailable`: The branch's environment couldn't
            start. `github_workspace_connection_required`: The repository isn't
            connected to GitHub in the app's workspace.
          content:
            application/json:
              examples:
                git_discard_failed:
                  summary: git_discard_failed
                  value:
                    error:
                      code: git_discard_failed
                      message: Could not discard the changes
                      details:
                        reason: git_discard_failed
                app_processing:
                  summary: app_processing
                  value:
                    error:
                      code: app_processing
                      message: >-
                        App is still generating - wait for the current turn to
                        finish before discarding changes
                      details:
                        reason: app_processing
                        operation: discarding changes
              schema:
                $ref: '#/components/schemas/StandardErrorEnvelope'
        '429':
          description: >-
            `rate_limited`: More than 10 requests in a minute. Retry after
            `Retry-After` seconds.
          content:
            application/json:
              examples:
                rate_limited:
                  summary: rate_limited
                  value:
                    error:
                      code: rate_limited
                      message: Rate limit exceeded.
                      details: {}
              schema:
                $ref: '#/components/schemas/StandardErrorEnvelope'
      security:
        - PersonalAccessTokenAuth:
            - full_access
components:
  schemas:
    BranchGitStatus:
      properties:
        current_branch:
          type: string
          title: Current Branch
          description: >-
            Branch checked out in the branch's environment, or `HEAD` when none
            is checked out.
          example: feature/checkout
        default_branch:
          type: string
          title: Default Branch
          description: The repository's default branch on GitHub.
          example: main
        base_branch:
          type: string
          title: Base Branch
          description: The branch the app was imported from. Pull requests merge into it.
          example: main
        head:
          anyOf:
            - type: string
            - type: 'null'
          title: Head
          description: SHA of the latest commit, or `null` when the branch has no commits.
          example: 9fceb02d0ae598e95dc970b74767f19372d61af8
        head_committed_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Head Committed At
          description: >-
            When the latest commit was made, as an ISO 8601 UTC timestamp, or
            `null`.
          example: '2026-10-28T09:15:00Z'
        dirty:
          type: boolean
          title: Dirty
          description: Whether there are uncommitted changes.
          example: true
        dirty_files:
          items:
            type: string
          type: array
          title: Dirty Files
          description: >-
            Paths of the first 20 files with uncommitted changes. A renamed file
            reads `old -> new`.
          example:
            - src/pages/Checkout.jsx
        ahead:
          anyOf:
            - type: integer
            - type: 'null'
          title: Ahead
          description: >-
            Commits not pushed to GitHub yet, or `null` when the branch isn't on
            GitHub.
          example: 1
        behind:
          anyOf:
            - type: integer
            - type: 'null'
          title: Behind
          description: >-
            Commits on GitHub the environment doesn't have yet, as of its last
            fetch, or `null` when the branch isn't on GitHub.
          example: 0
        merge_in_progress:
          type: boolean
          title: Merge In Progress
          description: >-
            Whether a merge is under way, for example while conflicts are
            resolved.
          example: false
      type: object
      required:
        - current_branch
        - default_branch
        - base_branch
        - head
        - head_committed_at
        - dirty
        - dirty_files
        - ahead
        - behind
        - merge_in_progress
      title: BranchGitStatus
    StandardErrorEnvelope:
      properties:
        error:
          $ref: '#/components/schemas/StandardError'
          description: What went wrong.
      type: object
      required:
        - error
      title: StandardErrorEnvelope
      description: The error body returned in the standard envelope.
    StandardError:
      properties:
        code:
          type: string
          title: Code
          description: >-
            Stable machine-readable cause of the failure. Match on this, not on
            `message`.
          example: not_found
        message:
          type: string
          title: Message
          description: Human-readable explanation. It isn't a stable contract.
          example: App not found
        details:
          additionalProperties: true
          type: object
          title: Details
          description: >-
            Structured context for the failure, or an empty object when there's
            none.
          example: {}
      type: object
      required:
        - code
        - message
      title: StandardError
  securitySchemes:
    PersonalAccessTokenAuth:
      type: http
      scheme: bearer
      description: >-
        Personal access token, sent as `Authorization: Bearer <token>`. Each
        operation lists the permission it needs: `read_only` or `full_access`. A
        full-access token can call every operation. A read-only token can call
        only the operations that list `read_only`; anything else returns 403
        `read_only_credential_route_not_allowed`.

````

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