# Merging Branches

### About this export

| Field | Value |
| --- | --- |
| **content_type** | lesson |
| **platform** | contentstack-academy |
| **source_url** | https://www.contentstack.com/academy/courses/branches-foundations/merging-branches |
| **course_slug** | branches-foundations |
| **lesson_slug** | merging-branches |
| **markdown_file_url** | /academy/md/courses/branches-foundations/merging-branches.md |
| **generated_at** | 2026-04-28T06:55:36.460Z |

> Part of **[Branches Foundations](https://www.contentstack.com/academy/courses/branches-foundations)** on Contentstack Academy. **Academy MD v3** — structured for retrieval; no quiz or assessment keys.

<!-- ai_metadata: {"lesson_id":"07","type":"text","duration_minutes":1,"topics":["Merging","Branches"]} -->

#### Lesson text

The Branch Merging feature enables you to merge changes between two branches using various available merge strategies. When merging two branches, you select a base branch where changes will be merged and a compare branch that contains the changes to be merged.

**Note:** The Merge feature currently only merges differences between content type and global field modules and is **only available via** [**Content Management API**](https://www.contentstack.com/docs/developers/apis/content-management-api/#merging-branches) **and** [**CLI commands**](https://www.contentstack.com/docs/developers/cli/compare-and-merge-branches-using-the-cli/).  
**The default behavior when merging will create a backup of the branch you are merging into for safety. You can use this to quickly revert your site if there is an issue with the merge via an alias.**  
**Note:** You can create an additional revert branch beyond the established maximum limit of branches per stack. For instance, if you already have reached the maximum limit of branches in your stack, you can perform a merge operation, provided that you manually delete the backup branch or any other branch before attempting the next merge.  

## **Strategies to Merge Branches**

You can merge two branches using the following strategies:

**Warning:** Make sure to select the correct strategy for your merge operation.

Strategy

Description

Prefer base

Add changes from the compare branch to the base branch. In case of conflicts, keep changes in the base branch and ignore changes in the compare branch.

Prefer compare

Add changes from the compare branch to the base branch. In case of conflicts, keep changes in the compare branch and discard changes in the base branch.

Overwrite with compare

Completely replace the base branch with changes from the compare branch. Any items in the base branch not present in the compare branch will be lost.

Merge new only

Merge only new changes from the compare branch to the base branch, ignoring any modified changes in the compare branch.

Merge modified with prefer base

Add only modified changes from the compare branch to the base branch. In conflicts, keep modified changes of the base branch and ignore modified changes of the compare branch.

Merge modified with prefer compare

Add only modified changes from the compare branch to the base branch. In conflicts, keep modified changes of the compare branch and ignore modified changes of the base branch.

Ignore

Ignore all changes from the compare branch, keeping the base branch unchanged. Can be used to ignore specific changes or all changes to merge only specific changes.

**Note:** You can use ignore as the default merge strategy and different merge strategies for all or specific content types and global fields.

## **Use-Cases of Merging Branches**

Consider a scenario in our academy training instance consisting of the following content types:

*   **Author**: with fields "First Name," "Last Name," "Author Pic," "Bio"
    

![BranchesFoundations-L7-img-1.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt9d4cbba11c147362/67dd814c2d0b98ec95fd0693/BranchesFoundations-L7-img-1.png)

Now, we plan to redesign our website and create a branch called **dev** that copies all of the above-mentioned content types from the main branch and their current content. You make the following structural changes to the content types within the child branch:

*   **Author**: with the “Rating” (new) fields (and the “Bio” field removed) and First Name and Last Name is changed to Author First Name and Author Last Name.
    
*   **Branch Demo Dev:** with field "Title"  
    

![BranchesFoundations-L7-img-2.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/bltf9516b569f7eab80/67dd8163632b93c6e2d4a241/BranchesFoundations-L7-img-2.png)

  

![BranchesFoundations-L7-img-3.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt4778cdee505a0fb1/67dd8176986725826f888a33/BranchesFoundations-L7-img-3.png)

  

![BranchesFoundations-L7-img-4.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/bltf8f1e3ca9a6bcde4/67dd818d632b9305cfd4a248/BranchesFoundations-L7-img-4.png)

While the main branch will add the new content type

We will add a new content type named "**Branch Demo Main,**" with the field **"Title"** and a new field named **"Date Of Birth."** 

![BranchesFoundations-L7-img-5.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt98e16353a6394bf5/67dd81a4c5de53ace9d2e274/BranchesFoundations-L7-img-5.png)

Let us understand how each of the strategies affects our merge function individually.

Please consider the color codes.

![BranchesFoundations-L7-img-6.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt31b390eacb3dee77/67dd81ba983a65414e3b7c7c/BranchesFoundations-L7-img-6.png)

  

![BranchesFoundations-L7-img-7.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt8d57d5e37a1e8112/67dd81dbc9b8d42887d1421f/BranchesFoundations-L7-img-7.png)

### We will merge branches using [Contentstack Management API](https://www.contentstack.com/docs/developers/apis/content-management-api#merge-branches) 

### **Merge Using Prefer Base**

Since this strategy allows you to add changes from the compare branch to the base branch, and in case of conflicts, prefer to keep content from the base branch intact. Your new merged main branch will be as follows (items in bold came from the compare branch):

*   **Author**: with fields "First Name," "Last Name," "Author Pic," "Bio," "**Rating**," "Date Of Birth." 
    
*   **Branch Demo Main:** with field "Title"
    
*   **Branch Demo Dev: with field "Title"**
    

### 

![BranchesFoundations-L7-img-8.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/bltcc6eb480d8c3eecd/67dd81f0983a653c3e3b7c84/BranchesFoundations-L7-img-8.png)

### 

![BranchesFoundations-L7-img-9.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blte754d01206810d09/67dd82054a89c30e99a30365/BranchesFoundations-L7-img-9.png)

### 

![BranchesFoundations-L7-img-10.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/bltd8a58a4ae3faca87/67dd821a45b22905b89116e5/BranchesFoundations-L7-img-10.png)

### **Merge Using Prefer Compare**

Since this strategy allows you to add changes from the compare branch to the base branch, and in case of conflicts, prefer to keep content from the compare branch intact. Your new merged main branch will be as follows (items in bold came from the compare branch):

*   **Author**: with fields "**Author First Name**", "**Author Last Name**," "Author Pic," "Bio," "**Rating**," "Date Of Birth."
    
*   **Branch Demo Main:** with field "Title"
    
*   **Branch Demo Dev:** with field "**Title**"
    

### 

![BranchesFoundations-L7-img-11.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt1e2dc33fbe4b5440/67dd82352d0b985ba5fd069c/BranchesFoundations-L7-img-11.png)

### 

![BranchesFoundations-L7-img-12.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blta0cb5f260d99a07c/67dd8249dd73e3af00bf34e7/BranchesFoundations-L7-img-12.png)

### 

![BranchesFoundations-L7-img-13.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt10d2f26218b71603/67dd825ec566eec1d85e00b3/BranchesFoundations-L7-img-13.png)

### **Merge Using Overwrite with Compare**

This strategy allows you to completely overwrite the base branch with the changes from the compare branch. Your new merged main branch will be as follows (everything comes from the compare branch):

*   **Author**: with fields "**Author First Name**", "**Author Last Name**," "Author Pic," "**Rating**,"
    
*   **Branch Demo Dev:** with field "**Title**"
    

### 

![BranchesFoundations-L7-img-14.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/bltb917952d969c34ba/67dd8277037e2b555e22da46/BranchesFoundations-L7-img-14.png)

### 

![BranchesFoundations-L7-img-15.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt5ccbbae3163714ec/67dd828ea7145831d3b9b623/BranchesFoundations-L7-img-15.png)

### 

![BranchesFoundations-L7-img-16.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/bltaa777f1c381733d9/67dd82a4460eb4682294783a/BranchesFoundations-L7-img-16.png)

### **Merge Using New Only**

This strategy allows you to add only new changes from the compare branch to the base branch. Your new merged main branch will be as follows (items in bold came from the compare branch):

*   **Author**: with fields "First Name," "Last Name," "Author Pic," "Bio," "Date Of Birth." 
    
*   **Branch Demo Main:** with field "Title"
    
*   **Branch Demo Dev:** with field "**Title**"
    

### 

![BranchesFoundations-L7-img-17.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt2dd3fcb93060adca/67dd82ba9867258250888a60/BranchesFoundations-L7-img-17.png)

### 

![BranchesFoundations-L7-img-18.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/bltdcdac9a60f1e2497/67dd82ce4a89c35208a30373/BranchesFoundations-L7-img-18.png)

### 

![BranchesFoundations-L7-img-19.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt88ec71d73dabebe0/67dd82e2460eb4f3ff947844/BranchesFoundations-L7-img-19.png)

### **Merge Using Modified With Prefer Base**

Since this strategy allows you to add only modified changes from the compare branch to the base branch, and in case of conflicts, prefer to keep content from the base branch intact. All newly added items are ignored during the merge. Your new merged main branch will be as follows (items in bold came from the compare branch):

*   **Author**: with fields "First Name," "Last Name," "Author Pic," "Bio," "**Rating**," "Date Of Birth." 
    
*   **Branch Demo Main:** with field "Title"
    

### 

![BranchesFoundations-L7-img-20.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/bltb4ef14c242c59100/67dd82fac5de539a19d2e288/BranchesFoundations-L7-img-20.png)

### 

![BranchesFoundations-L7-img-21.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/bltea84982a14a81f3b/67dd8310c9b8d48b7dd14236/BranchesFoundations-L7-img-21.png)

### 

![BranchesFoundations-L7-img-22.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/bltccb4a7f1d231d5e3/67dd832a339f2953af8b6121/BranchesFoundations-L7-img-22.png)

### **Merge Using Modified With Prefer Compare**

Since this strategy allows you to add only modified changes from the compare branch to the base branch, and in case of conflicts, prefer to keep content from the compare branch intact. All newly added items are ignored during the merge. Your new merged main branch will be as follows (items in bold came from the compare branch):

*   **Author**: with fields "**Author First Name**," "**Author Last Name**," "Author Pic," "Bio," "**Rating**," "Date Of Birth." 
    
*   **Branch Demo Main:** with field "Title"
    

![BranchesFoundations-L7-img-23.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt665d0f88b5ae61b0/67dd8342037e2b1ff222da51/BranchesFoundations-L7-img-23.png)

![BranchesFoundations-L7-img-24.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt1ad65b17b089f24d/67dd8357782bfb4e626f567e/BranchesFoundations-L7-img-24.png)

![BranchesFoundations-L7-img-25.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt92dff45c8b269449/67dd836e45b22935ef911709/BranchesFoundations-L7-img-25.png)  

# **Merging using the CLI**

You can refer to a complete reference documentation over [here](https://www.contentstack.com/docs/developers/cli/compare-and-merge-branches-using-the-cli#steps-to-merge-branches)

**Usage**

  
csdx cm:branches:merge  

or

  
csdx cm:branches:merge --stack-api-key --base-branch --compare-branch  

**Options**

*   \-k, --stack-api-key=stack-api-key: Stack API key.
    
*   \--base-branch=base-branch: Base Branch.
    
*   \--compare-branch=compare-branch: Compare branch.
    
*   \--comment=comment: Pass a comment.
    
*   \--export-summary-path=export-summary-path: Export summary file path.
    
*   \--use-merge-summary=use-merge-summary: Path of merge summary file.
    
*   \--no-revert=no-revert: If passed, will not create the new revert branch.
    

**Examples**

  
csdx cm:branches:merge --stack-api-key bltxxxxxxxx --compare-branch feature-branch  

  
csdx cm:branches:merge --export-summary-path file/path

*   To merge feature-branch with the base branch for a stack.
    
*   To merge branches and export the results summary to a file path.
    

  

## **Steps to Merge Branches**

**Follow the steps below to merge two branches:**

**1) Enter the following command to merge two branches:**

csdx cm:branches:merge

**2) Enter the Stack API key where you want to merge the branches.**

**3) Enter the name of the compare branch.**

By default, the current base branch will be automatically used.

Alternatively, you can pass the Stack API key, base branch, and compare branch in the command as given below: csdx cm:branches:merge --stack-api-key --base-branch --compare-branch

**Note**: If you want to choose a different base branch other than the default one, you must specify the flag for the base branch as given in the command above.

The branches' compare results will be displayed as Content Types Summary and Global Fields Summary for individual modules.

**4) Choose a merge strategy from the displayed list.**

**Merge, Prefer Base:** Adds all changes from the compare branch to the base branch. In case of any conflicts, the preference goes to the base branch.

**Merge, Prefer to Compare:** Adds all changes from the compare branch to the base branch. In case of any conflicts, the preference goes to the compare branch.

**Merge, Ask for Preference:** Asks you to choose how to merge every difference individually at the content type or global field level.

**Overwrite with Compare:** Replace the base branch with the compare branch. Anything in the base branch that is not in the compare branch is removed.  
**5)** If you choose **Merge, Prefer Base** or **Merge, Prefer Compare** from **step 4**, choose what you want to merge from the following list:

*   **New in Compare Only**: Adds only new items from the compare branch to the base branch. All the items that are modified are ignored.
    
*   **Modified Only**: Only modified items are added from the compare branch to the base branch. All the new items are ignored.
    
*   **Both**: Adds both new and modified items from the compare branch to the base branch.
    
*   **Go Back**: This takes you back to the previous step.
    
*   **Start Over**: This takes you back to step 4.
    

**6)** If you choose **Overwrite with Compare** from **Step 4**, or **New in Compare Only, Modified Only, or Both from Step 5**, choose what you want to do next from the following list:

**Execute Merge**: Executes the merge action and exports the merge result summary to the specified location.

**Export Merge Summary**: Exports the merge result summary to the specified location but does not execute the merge action. This can be used to apply the merge later. \\

**Execute Merge and Generate Content Migration Scripts**: Executes merge action, exports merge result summary to the specified location, and generates the entries migration script.

**Export Summary and Generate Content Migration Scripts**: Exports merge result summary to the specified location and generate the entries migration script. Go Back: This takes you back to the previous step. Start Over: This takes you back to step 4.

**7)** If you choose **Execute Merge and Generate Content Migration Scripts** or **Export Summary and Generate Content Migration Scripts** from **Step 6**, choose what you want to do next from the following list:

*   **Both existing and new**: Generates script for both new and modified entries.
    
*   **New only**: Generates script for the new entries.
    
*   **Existing only**: Generates script for the updated entries.
    
*   **Ask for preference**: If you choose this option, the following table displays:
    

Choose what you want to do next from the following list:

*   **Merge New Only**: Generates script for the new entries.
    
*   **Merge Modified Only**: Generates script for the updated entries.
    
*   **Merge Both**: Generates script for both new and modified entries.
    
*   **Ignore**: Ignores entries from a particular content type.   
    

**8)** If you choose **Merge, Ask for Preference** from step 4; follow the steps below:

1.  Select the **content type changes** for merge from the provided tabular column. With this, you can modify/add/remove only those content types from a selected branch during the merge operation. 
    
2.  Select the **global field changes** for merge from the provided tabular column. With this, you can modify/add/remove only those global fields from a selected branch during the merge operation.
    
3.  In the next step, choose what you want to merge from the following list:
    
    *   **Execute Merge**: Executes the merge action and exports the merge result summary to the specified location.
        
    *   **Export Merge Summary**: Exports the merge result summary to the specified location but does not execute the merge action.
        
    *   **Execute Merge and Generate Content Migration Scripts**: Executes merge action, exports merge result summary to the specified location and generates the entries migration script.
        
    *   **Export Summary and Generate Content Migration Scripts**: Exports merge result summary to the specified location and generate the entries migration script.
        
    *   **Go Back**: This takes you back to the previous step.
        
    *   **Start Over**: This takes you back to step 4.
        
    
4.  If you choose **Execute Merge and Generate Content Migration Scripts** or **Export Summary and Generate Content Migration Scripts** from the above step, follow the steps in step 7.  
      
    **Note:** If you want to ignore the changes in the compare branch for a specific content type, select the **Ignore(Use Base)** option for that content type.  
      
    **Tip**: Use the **arrow keys** to move along the table cells and then hit the **spacebar** to make the selection.  
      
    **Note:** If you want to ignore the changes in the compare branch for a specific global field, select the **Ignore(Use Base)** option for that global field.  
      
    **1\. merge prefer base**  
      
    
    ![BranchesFoundations-L7-img-26.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/bltf602b011e12320b5/67dd8389983a655f433b7c9e/BranchesFoundations-L7-img-26.png)  
      
    **2\. merge prefer compare**  
      
    
    ![BranchesFoundations-L7-img-27.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt10a070cb1578a8d6/67dd839f37e25a728b1e4663/BranchesFoundations-L7-img-27.png)  
      
    **3. overwrite with compare**  
      
    
    ![BranchesFoundations-L7-img-28.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/bltcde009a71ed317f2/67dd83b5443bd674ccf1cb70/BranchesFoundations-L7-img-28.png)  
      
    **4. merge new only**  
      
    
    ![BranchesFoundations-L7-img-29.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt4e7ba8dafe17d654/67dd83ce983a654a4c3b7ca6/BranchesFoundations-L7-img-29.png)  
      
    **5. merge modified only prefer base**  
      
    
    ![BranchesFoundations-L7-img-30.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt736923d0295c9927/67dd83e3a6d88e2682053521/BranchesFoundations-L7-img-30.png)  
      
    **6. merge modified only prefer compare**  
      
    
    ![BranchesFoundations-L7-img-31.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/bltf6c25016fc7e1097/67dd83f8460eb4f457947879/BranchesFoundations-L7-img-31.png)  
      
    

# **Merging Entries and Assets - Using Content Migration Script for Entries**

**Note:**

1.  Only newly created or modified entries and assets belonging to modified or newly created content types will be migrated to the base branch, based on the strategy chosen during branch merging. Ensure that these changes align with your migration strategy and review the generated scripts accordingly.
    
2.  Keep in mind that the behavior of the CLI may vary across different platforms and machines. Be aware of any platform-specific nuances or differences in CLI behavior that may affect the merging and migration process.
    
3.  For Windows OS, please run the following commands first:  
    npm link lodash  
    npm link marked  
    npm link @contentstack/cli-utilities
    
4.  Please execute the generated script from the same location where the Contentstack CLI is installed to ensure proper execution and avoid any path-related issues.
    

**1\. Create Dev Feature Branch:**  
   - Create branch "dev" from your Contentstack main branch.

**2\. Make Changes in the "dev" Branch:**  
   - Inside the "**dev**" branch, navigate to the **Author** content type.  
   - Add a new field named "**Rating**" to the **Author** content type.  
  

![BranchesFoundations-L7-img-32.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blta28eef0fdda2ceae/67dd8411986725f6a5888a76/BranchesFoundations-L7-img-32.png)  
   - **Update an existing entry in the Author content type** by adding a rating value.  
  

![BranchesFoundations-L7-img-33.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/bltddbbf1aa70ad4bc5/67dd8427c566ee24c45e00eb/BranchesFoundations-L7-img-33.png)  
   - **Create a new entry in the Author content type that includes a new asset**.  
  
![BranchesFoundations-L7-img-34.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/bltbdc7e9d6a16b56e8/67dd8442efd8a9c1d34c012f/BranchesFoundations-L7-img-34.png)

  
![BranchesFoundations-L7-img-35.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt2d4888ac952a80af/67dd845837e25af3f11e4674/BranchesFoundations-L7-img-35.png)  

  

**3\. Merge "dev" into "main" with Merge Prefer Base Option:**  
   - Initiate the merge process from the "main" branch.  
  

![BranchesFoundations-L7-img-36.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/bltea647767157831a5/67dd846d339f297f798b6135/BranchesFoundations-L7-img-36.png)  
  
   - Use the "Merge Prefer Base" option to ensure that conflicts are resolved by favoring the changes in the base (target) branch.  
   - If using the CLI, execute the merge command with the appropriate options.  
  

![BranchesFoundations-L7-img-37.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt9e3d0cc04fd681bb/67dd8481c9b8d4d16ed1424c/BranchesFoundations-L7-img-37.png)  
  
**4\. Generate Content Migration Scripts:**  
   - If prompted, choose the option to execute the merge and generate content migration scripts or export summary and generate content migration scripts.  
   - The CLI will generate scripts based on the changes between the "dev" and "main" branches.

**5\. Review and Execute Scripts (If Applicable):**  
   - Review the generated content migration scripts to ensure they reflect the desired changes accurately.  
   - If executing the merge and migration scripts separately, follow the instructions provided by the CLI to execute the scripts.  
  
![BranchesFoundations-L7-img-38.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt3c998ae9802f2654/67dd84a40c6f55d96d1fcf78/BranchesFoundations-L7-img-38.png)

**6\. Verify Changes in the "main" Branch:**  
   - Once the merge process and content migration are complete, switch to the "main" branch.  
   - Check that the changes from the "dev" branch, including the new field, updated entry, and new entry with the asset, are successfully reflected in the "main" branch.

## **Changes in Assets**

  

![BranchesFoundations-L7-img-39.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt3ef332d207e1f7ab/67dd84bb782bfb81cd6f569e/BranchesFoundations-L7-img-39.png)  
  

## **Changes in Entries**

**1) Newly created entry**   

![BranchesFoundations-L7-img-40.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/bltde24a4b36ccd364a/67dd850aa6d88e07eb053538/BranchesFoundations-L7-img-40.png)

![BranchesFoundations-L7-img-41.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt39f7706c0d7ae658/67dd851f45b2298406911758/BranchesFoundations-L7-img-41.png)

  
**2) Updated Entry**   
![BranchesFoundations-L7-img-42.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/bltd8799b82119f1b29/67dd8537443bd6a2d1f1cb8f/BranchesFoundations-L7-img-42.png)

**7\. Cleanup (Optional):**  
   - Once changes are successfully merged and deployed, you can optionally delete the "dev" branch if it's no longer needed.

# **Further Reference**

*   [Merging branches using API](https://www.contentstack.com/docs/developers/apis/content-management-api/#merging-branches)
    
*   [Steps to merge branches](https://www.contentstack.com/docs/developers/cli/compare-and-merge-branches-using-the-cli/#steps-to-merge-branches)
    
*   [Merging branches using CLI](https://www.contentstack.com/docs/developers/cli/compare-and-merge-branches-using-the-cli/)
    
*   [Entry migration using CLI](https://www.contentstack.com/docs/developers/cli/entry-migration)

#### Key takeaways

- Connect **Merging Branches** back to your stack configuration before moving to the next module.
- Capture one concrete artifact (screenshot, Postman call, or code snippet) that proves the step works in your environment.
- Re-read the delivery versus management boundary for anything you changed in the entry model.

## Supplement for indexing

### Content summary

Merging Branches. The Branch Merging feature enables you to merge changes between two branches using various available merge strategies. When merging two branches, you select a base branch where changes will be merged and a compare branch that contains the changes to be merged. Note: The Merge feature currently only merges differences between content type and global field modules and is only available via Content Management API (https://www.contentstack.com/docs/developers/apis/content-management-api/ merging-branches) and CLI commands (https://www.contentstack.com/docs/developers/cli/compare-and-merge-branches-using-the-cli/). The default behavior when merging will create a backup of the branch you are mergi

### Retrieval tags

- Merging
- Branches
- branches-foundations
- lesson 07
- Merging Branches
- branches-foundations lesson

### Indexing notes

Index this lesson as a primary chunk tagged with lesson_id "07" and topics: [Merging, Branches].
Parent course slug: branches-foundations. Use asset_references URLs as thumbnail hints in search results when present.
Never surface LMS quiz content or assessment answers from this file.

### Asset references

| Label | URL |
| --- | --- |
| BranchesFoundations-L7-img-1.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt9d4cbba11c147362/67dd814c2d0b98ec95fd0693/BranchesFoundations-L7-img-1.png` |
| BranchesFoundations-L7-img-2.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/bltf9516b569f7eab80/67dd8163632b93c6e2d4a241/BranchesFoundations-L7-img-2.png` |
| BranchesFoundations-L7-img-3.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt4778cdee505a0fb1/67dd8176986725826f888a33/BranchesFoundations-L7-img-3.png` |
| BranchesFoundations-L7-img-4.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/bltf8f1e3ca9a6bcde4/67dd818d632b9305cfd4a248/BranchesFoundations-L7-img-4.png` |
| BranchesFoundations-L7-img-5.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt98e16353a6394bf5/67dd81a4c5de53ace9d2e274/BranchesFoundations-L7-img-5.png` |
| BranchesFoundations-L7-img-6.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt31b390eacb3dee77/67dd81ba983a65414e3b7c7c/BranchesFoundations-L7-img-6.png` |
| BranchesFoundations-L7-img-7.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt8d57d5e37a1e8112/67dd81dbc9b8d42887d1421f/BranchesFoundations-L7-img-7.png` |
| BranchesFoundations-L7-img-8.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/bltcc6eb480d8c3eecd/67dd81f0983a653c3e3b7c84/BranchesFoundations-L7-img-8.png` |
| BranchesFoundations-L7-img-9.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blte754d01206810d09/67dd82054a89c30e99a30365/BranchesFoundations-L7-img-9.png` |
| BranchesFoundations-L7-img-10.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/bltd8a58a4ae3faca87/67dd821a45b22905b89116e5/BranchesFoundations-L7-img-10.png` |
| BranchesFoundations-L7-img-11.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt1e2dc33fbe4b5440/67dd82352d0b985ba5fd069c/BranchesFoundations-L7-img-11.png` |
| BranchesFoundations-L7-img-12.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blta0cb5f260d99a07c/67dd8249dd73e3af00bf34e7/BranchesFoundations-L7-img-12.png` |
| BranchesFoundations-L7-img-13.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt10d2f26218b71603/67dd825ec566eec1d85e00b3/BranchesFoundations-L7-img-13.png` |
| BranchesFoundations-L7-img-14.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/bltb917952d969c34ba/67dd8277037e2b555e22da46/BranchesFoundations-L7-img-14.png` |
| BranchesFoundations-L7-img-15.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt5ccbbae3163714ec/67dd828ea7145831d3b9b623/BranchesFoundations-L7-img-15.png` |
| BranchesFoundations-L7-img-16.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/bltaa777f1c381733d9/67dd82a4460eb4682294783a/BranchesFoundations-L7-img-16.png` |
| BranchesFoundations-L7-img-17.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt2dd3fcb93060adca/67dd82ba9867258250888a60/BranchesFoundations-L7-img-17.png` |
| BranchesFoundations-L7-img-18.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/bltdcdac9a60f1e2497/67dd82ce4a89c35208a30373/BranchesFoundations-L7-img-18.png` |
| BranchesFoundations-L7-img-19.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt88ec71d73dabebe0/67dd82e2460eb4f3ff947844/BranchesFoundations-L7-img-19.png` |
| BranchesFoundations-L7-img-20.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/bltb4ef14c242c59100/67dd82fac5de539a19d2e288/BranchesFoundations-L7-img-20.png` |
| BranchesFoundations-L7-img-21.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/bltea84982a14a81f3b/67dd8310c9b8d48b7dd14236/BranchesFoundations-L7-img-21.png` |
| BranchesFoundations-L7-img-22.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/bltccb4a7f1d231d5e3/67dd832a339f2953af8b6121/BranchesFoundations-L7-img-22.png` |
| BranchesFoundations-L7-img-23.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt665d0f88b5ae61b0/67dd8342037e2b1ff222da51/BranchesFoundations-L7-img-23.png` |
| BranchesFoundations-L7-img-24.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt1ad65b17b089f24d/67dd8357782bfb4e626f567e/BranchesFoundations-L7-img-24.png` |
| BranchesFoundations-L7-img-25.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt92dff45c8b269449/67dd836e45b22935ef911709/BranchesFoundations-L7-img-25.png` |
| BranchesFoundations-L7-img-26.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/bltf602b011e12320b5/67dd8389983a655f433b7c9e/BranchesFoundations-L7-img-26.png` |
| BranchesFoundations-L7-img-27.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt10a070cb1578a8d6/67dd839f37e25a728b1e4663/BranchesFoundations-L7-img-27.png` |
| BranchesFoundations-L7-img-28.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/bltcde009a71ed317f2/67dd83b5443bd674ccf1cb70/BranchesFoundations-L7-img-28.png` |
| BranchesFoundations-L7-img-29.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt4e7ba8dafe17d654/67dd83ce983a654a4c3b7ca6/BranchesFoundations-L7-img-29.png` |
| BranchesFoundations-L7-img-30.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt736923d0295c9927/67dd83e3a6d88e2682053521/BranchesFoundations-L7-img-30.png` |
| BranchesFoundations-L7-img-31.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/bltf6c25016fc7e1097/67dd83f8460eb4f457947879/BranchesFoundations-L7-img-31.png` |
| BranchesFoundations-L7-img-32.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blta28eef0fdda2ceae/67dd8411986725f6a5888a76/BranchesFoundations-L7-img-32.png` |
| BranchesFoundations-L7-img-33.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/bltddbbf1aa70ad4bc5/67dd8427c566ee24c45e00eb/BranchesFoundations-L7-img-33.png` |
| BranchesFoundations-L7-img-34.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/bltbdc7e9d6a16b56e8/67dd8442efd8a9c1d34c012f/BranchesFoundations-L7-img-34.png` |
| BranchesFoundations-L7-img-35.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt2d4888ac952a80af/67dd845837e25af3f11e4674/BranchesFoundations-L7-img-35.png` |
| BranchesFoundations-L7-img-36.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/bltea647767157831a5/67dd846d339f297f798b6135/BranchesFoundations-L7-img-36.png` |
| BranchesFoundations-L7-img-37.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt9e3d0cc04fd681bb/67dd8481c9b8d4d16ed1424c/BranchesFoundations-L7-img-37.png` |
| BranchesFoundations-L7-img-38.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt3c998ae9802f2654/67dd84a40c6f55d96d1fcf78/BranchesFoundations-L7-img-38.png` |
| BranchesFoundations-L7-img-39.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt3ef332d207e1f7ab/67dd84bb782bfb81cd6f569e/BranchesFoundations-L7-img-39.png` |
| BranchesFoundations-L7-img-40.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/bltde24a4b36ccd364a/67dd850aa6d88e07eb053538/BranchesFoundations-L7-img-40.png` |
| BranchesFoundations-L7-img-41.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt39f7706c0d7ae658/67dd851f45b2298406911758/BranchesFoundations-L7-img-41.png` |
| BranchesFoundations-L7-img-42.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/bltd8799b82119f1b29/67dd8537443bd6a2d1f1cb8f/BranchesFoundations-L7-img-42.png` |

### External links

| Label | URL |
| --- | --- |
| Contentstack Academy home | `https://www.contentstack.com/academy/` |
| Training instance setup | `https://www.contentstack.com/academy/training-instance` |
| Academy playground (GitHub) | `https://github.com/contentstack/contentstack-academy-playground` |
| Contentstack documentation | `https://www.contentstack.com/docs/` |
| **Content Management API** | `https://www.contentstack.com/docs/developers/apis/content-management-api/#merging-branches` |
| **CLI commands** | `https://www.contentstack.com/docs/developers/cli/compare-and-merge-branches-using-the-cli/` |
| BranchesFoundations-L7-img-1.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt9d4cbba11c147362/67dd814c2d0b98ec95fd0693/BranchesFoundations-L7-img-1.png` |
| BranchesFoundations-L7-img-2.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/bltf9516b569f7eab80/67dd8163632b93c6e2d4a241/BranchesFoundations-L7-img-2.png` |
| BranchesFoundations-L7-img-3.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt4778cdee505a0fb1/67dd8176986725826f888a33/BranchesFoundations-L7-img-3.png` |
| BranchesFoundations-L7-img-4.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/bltf8f1e3ca9a6bcde4/67dd818d632b9305cfd4a248/BranchesFoundations-L7-img-4.png` |
| BranchesFoundations-L7-img-5.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt98e16353a6394bf5/67dd81a4c5de53ace9d2e274/BranchesFoundations-L7-img-5.png` |
| BranchesFoundations-L7-img-6.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt31b390eacb3dee77/67dd81ba983a65414e3b7c7c/BranchesFoundations-L7-img-6.png` |
| BranchesFoundations-L7-img-7.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt8d57d5e37a1e8112/67dd81dbc9b8d42887d1421f/BranchesFoundations-L7-img-7.png` |
| Contentstack Management API | `https://www.contentstack.com/docs/developers/apis/content-management-api#merge-branches` |
| BranchesFoundations-L7-img-8.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/bltcc6eb480d8c3eecd/67dd81f0983a653c3e3b7c84/BranchesFoundations-L7-img-8.png` |
| BranchesFoundations-L7-img-9.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blte754d01206810d09/67dd82054a89c30e99a30365/BranchesFoundations-L7-img-9.png` |
| BranchesFoundations-L7-img-10.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/bltd8a58a4ae3faca87/67dd821a45b22905b89116e5/BranchesFoundations-L7-img-10.png` |
| BranchesFoundations-L7-img-11.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt1e2dc33fbe4b5440/67dd82352d0b985ba5fd069c/BranchesFoundations-L7-img-11.png` |
| BranchesFoundations-L7-img-12.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blta0cb5f260d99a07c/67dd8249dd73e3af00bf34e7/BranchesFoundations-L7-img-12.png` |
| BranchesFoundations-L7-img-13.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt10d2f26218b71603/67dd825ec566eec1d85e00b3/BranchesFoundations-L7-img-13.png` |
