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

# Merge Requests

> Review and apply code, variables, and secrets from one environment to another.

## Overview

Merge requests let you review environment changes before applying them to another environment. They compare a **source environment** with a **target environment**, show what will change, and then apply those changes when you merge.

Use merge requests to promote tested changes from `dev`, `staging`, or a feature environment into another environment, including protected `production`.

<Tip>
  **Cerebrum handles merge requests.** Ask "open a merge request from feature-auth to staging" or "review merge request for feature-123" — Cerebrum will create the request or guide the review.
</Tip>

## What a Merge Request Reviews

A merge request shows the differences between two environments:

| Change type         | What is reviewed                                                                                  |
| ------------------- | ------------------------------------------------------------------------------------------------- |
| Code                | Service code changes in the source environment branch compared with the target environment branch |
| Variables & Secrets | Variables and secrets that will be created or updated in the target environment                   |

The target environment is not changed while the merge request is open. Changes are applied only when the merge request is merged.

## How Merge Requests Work

<Steps>
  <Step title="Choose source and target">
    Select the environment that contains the changes and the environment that should receive them.
  </Step>

  <Step title="Review differences">
    Check code changes and Variables & Secrets changes relative to the target environment.
  </Step>

  <Step title="Check conflicts">
    Ardor checks whether the source environment branch can be merged into the target environment branch.
  </Step>

  <Step title="Merge">
    If there are no conflicts, Ardor merges the source environment branches into the target environment branches and applies variable changes.
  </Step>
</Steps>

## Applying Changes

When you merge a request:

* Source environment code branches are merged into the target environment code branches
* Variables and secrets from the source environment are created in the target environment when they do not exist there
* Existing variables and secrets in the target environment are updated with the source environment values

After the merge, the target environment contains the reviewed code and configuration changes from the source environment.

## Merge Conflicts

If code changes cannot be merged cleanly, Ardor shows the conflicts before the merge is applied. A merge request with conflicts cannot be merged until the conflicts are resolved.

Conflicts usually happen when the same code was changed differently in both the source and target environment branches. Review the conflict details, update the source or target environment, then try the merge again.

<Tip>
  **Cerebrum resolves the conflicts.** Ask "there is conflicts in merge request mr-123" - Cerebrum will find the way to finish the job.
</Tip>

## Typical Workflow

1. Make changes in `dev`, `staging`, or a feature environment
2. Test the source environment
3. Open a merge request into the environment you want to update
4. Review code, variables, and secrets changes
5. Resolve any conflicts if Ardor reports them
6. Merge the request

## Best Practices

<AccordionGroup>
  <Accordion title="Create merge requests from tested environments">
    Merge from an environment where you have already verified the code and configuration.
  </Accordion>

  <Accordion title="Review variables and secrets carefully">
    A code change can depend on new or updated runtime configuration. Make sure the target environment will receive the variables and secrets the code expects.
  </Accordion>

  <Accordion title="Keep target environments up to date">
    Merging smaller, frequent changes reduces the chance of code conflicts between environment branches.
  </Accordion>
</AccordionGroup>

## What's Next

<CardGroup cols="2">
  <Card title="Environments" icon="layer-group" href="/docs/environments/environments">
    Learn how environments isolate code, variables, and secrets
  </Card>

  <Card title="Variables & Secrets" icon="key" href="/docs/services/variables-and-secrets">
    Configure environment-specific runtime settings
  </Card>

  <Card title="Deployments" icon="rocket" href="/docs/environments/deployments">
    Deploy reviewed environment changes
  </Card>

  <Card title="Services Overview" icon="cube" href="/docs/services/service">
    Understand services and their configuration
  </Card>
</CardGroup>
