# Branches Foundations

### About this export

| Field | Value |
| --- | --- |
| **content_type** | course |
| **platform** | contentstack-academy |
| **source_url** | https://www.contentstack.com/academy/courses/branches-foundations |
| **language** | en |
| **product_area** | branches |
| **learning_path** | contentstack-developer-certification |
| **course_id** | branches-foundations |
| **slug** | branches-foundations |
| **version** | 2026-03-01 |
| **last_updated** | 2026-04-28 |
| **status** | published |
| **keywords** | ["branches","headless cms","composable","contentstack"] |
| **summary_one_line** | Branches Foundations This course will outline the Contentstack features and techniques for using Branches with your Contentstack implementation. Completion of this course earns a 'badge' for this topic. Pre-requisites fo… |
| **total_duration_minutes** | 67 |
| **lessons_count** | 11 |
| **video_lessons_count** | 0 |
| **text_lessons_count** | 11 |
| **linked_learning_path** | contentstack-developer-certification |
| **linked_assessment_ref** | LMS_UNCONFIGURED_COURSE_ASSESSMENT |
| **markdown_file_url** | /academy/md/courses/branches-foundations.md |
| **generated_at** | 2026-04-28T06:55:35.453Z |
| **intended_audience** | [] |
| **prerequisites** | [] |
| **related_courses** | [] |

> **Academy MD v3** — companion `.md` for Ask AI. Quizzes and graded assessments are **LMS-only**; this file never contains answer keys.

## Course Overview

| Metadata | Value |
| --- | --- |
| Catalog duration | 1h 6m 30s |
| Released (if known) | 2026-03-01 |
| Product area | branches |

### Description

# **Branches Foundations**

This course will outline the Contentstack features and techniques for using Branches with your Contentstack implementation. Completion of this course earns a 'badge' for this topic.

## **Pre-requisites for this course**

1.  Account in Contentstack with access to a Stack as an Administrator or Developer. Create a training Stack [here](https://www.contentstack.com/academy/). Training stacks are available for 90 days. Alternatively, you can bootstrap a [Starter App via the CLI](https://www.contentstack.com/docs/developers/cli/bootstrap-starter-apps) or the [Marketplace](https://app.contentstack.com/#!/marketplace/starters). 
    
2.  Permission to create new Content Types and Branches in a Stack.

### Learning objectives

1. Follow each lesson in order.
2. Practice in a training stack using placeholders **YOUR_STACK_API_KEY** and **YOUR_DELIVERY_TOKEN** in local `.env` files only.
3. Validate API responses against the official documentation.

### Topics covered

branches; headless cms; composable; contentstack

## Course structure

```text
branches-foundations/
├── 01-branches-in-contentstack · text · 1 min
├── 02-creating-branches-overview · text · 1 min
├── 03-creating-branches · text · 1 min
├── 04-working-with-branches-about-aliases · text · 1 min
├── 05-deleting-a-branch · text · 1 min
├── 06-comparing-branches · text · 1 min
├── 07-merging-branches · text · 1 min
├── 08-environments-and-branches · text · 1 min
├── 09-case-studies-with-branches · text · 1 min
├── 10-limitations-of-using-branches · text · 1 min
├── 11-branches-foundations-quiz · quiz (LMS only) · 3 min
```

## Lessons

### Lesson 01 — Branches in Contentstack

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

#### Lesson text

# **Definition of Branches in Contentstack**

In Contentstack, "Branches" play a pivotal role in content management by allowing users to create isolated copies of their stack into a new branch. A branch is a separate workspace where modifications can be made without immediately affecting the primary stack. Every stack has a **main** branch by default. To create a new branch, you can fork a new branch off of the main branch. This section will provide an introduction to the branches feature within Contentstack.

## **Why branches?**

  - **Definition and Purpose of Branches**: Branches contain a copy of the content types, entries, assets, and other items. They serve as containers for content modifications, enabling users to experiment and iterate without impacting the live content. The purpose of branches is to allow developers to change the content types and not affect the main 'production' branch.

  - **Importance of Content Isolation**: The concept of isolation ensures that changes made in one branch do not immediately reflect in the main branch, providing a controlled environment for content development

  - **Role in Controlled Content Modifications**: Branches allow developers to test changes methodically, facilitating version control and preventing unintended disruptions to the live content.

## **Example**:

Imagine a team of developers working on a large-scale website project using Contentstack as their content management system (CMS). Here's how they can effectively utilize the concept of "Branches" within Contentstack:

1.  **Testing New Features**: When the team wants to implement new features or design changes to the website, they can create a separate branch within Contentstack. This branch is a sandbox environment where developers can experiment with different ideas without affecting the live website.
    
2.  **Quality Assurance**: Before deploying any changes to the live website for a new feature, the team can thoroughly test them in the branch environment. This ensures that any bugs or issues are identified and resolved before they impact the user experience on the live site.
    
3.  **Collaborative Development**: Branches facilitate collaboration among team members by providing a centralized platform for making and reviewing changes to content types. Developers, designers, and content editors can all work together within their respective branches, sharing feedback and iterating on improvements.

#### Key takeaways

- Connect **Branches in Contentstack** 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.

### Lesson 02 — Creating Branches Overview

<!-- ai_metadata: {"lesson_id":"02","type":"text","duration_minutes":1,"topics":["Creating","Branches","Overview"]} -->

#### Lesson text

## **Creating Branches and Forking from the Main Branch**

To harness the power of branches, users need to understand how to create them and fork them from the main branch. This part of the module will guide users through the practical steps involved in initiating and establishing a new branch as an independent workspace.

### **Key Steps:**

  - **Creating a New Branch**: Users will learn the step-by-step process of creating a new branch within Contentstack, defining its purpose, and configuring its settings.

  - **Forking from the Main Branch**: The concept of forking involves duplicating the main branch to create a starting point for a new branch. This ensures that the new branch inherits the existing content structure.

  - **Initial Setup and Configuration**: Exploring the initial setup involves understanding how to configure the new branch, set permissions, and establish connections with other modules.

## **Source Branch Concept**

To navigate the world of branches effectively, it's essential to grasp the concept of the source branch. This part of the module will delve into the intricacies of the source branch, explaining its role in influencing subsequent branches and determining the initial set of inherited data.

  - **Definition and Role of Source Branch**: The source branch is called the **main** and acts as the parent from which new branches inherit their initial content structure and data. 

  - **Inherited Data from the Source Branch**: Content types, global fields, entries, assets, languages, webhooks, and extensions are among the elements inherited by child branches from the source branch. The versions of the content in the main branch are used at the time of the new branch creation and are not updated in the forked branch when the main branch changes.

  - **Establishing Source Branch Relationships**: Users will understand how to define and establish relationships between source and child branches, ensuring a structured workflow.

## **Inheriting Data in Branches**

**Understanding Source Branch and Inherited Data**

When working with branches in Contentstack, comprehending the relationship between the source branch and inherited data is crucial. This section delves into how child branches inherit their initial content structure from the designated source branch.

  **- Role of Source Branch:** The source branch acts as the origin or parent branch from which subsequent branches inherit their foundational content structure.  

  **- Inherited Data Flow**: An exploration of the seamless data flow from the source branch to child branches, ensuring consistency in content models.

**\- Impact on Workflow:** Understanding how the source branch influences the overall workflow of content creation and modifications in child branches.

**Example**:

Consider a scenario where a company's website has a standard template for product pages. By establishing a source branch with this template, any new branches created for specific product lines automatically inherit the standardized structure, streamlining the content creation process.

**Components Inherited:** Content Types, Global Fields, Entries, Assets, Languages, Webhooks, and Extensions

Contentstack branches inherit various components from the source branch, each playing a crucial role in shaping the content structure. This part of the module explores the inherited elements, emphasizing their impact on content development.

  **- Content Types:** The blueprint for structuring content, ensuring consistency in data representation.

  **- Global Fields:** Elements shared across different content types, promoting uniformity in data entry.

  **- Entries:** Individual content instances within a content type, inherited to maintain a cohesive database.

  **- Assets:** Media files such as images and documents shared among different branches.

  **- Languages:** Supporting multilingual content creation, ensuring global reach.

  **- Webhooks:** Automated notifications facilitating real-time updates.

  **- Extensions:** Custom functionalities extending the capabilities of Contentstack.

## **Independence of a Child Branch from the Parent Branch**

One of the key advantages of Contentstack branches lies in the independence they offer to child branches. This section explores how modifications made in a child branch do not directly impact the parent branch, facilitating a controlled and secure content development environment.

  **- Isolation of Changes:** Understanding how changes made in a child branch remain confined to that branch without affecting the source or other child branches.

**\- Testing and Iteration:** The ability to experiment and iterate in a child branch without immediate consequences on the live content.

  **- Controlled Development Environment:** Ensuring that content managers and developers can collaborate without disrupting ongoing processes in the source branch.

**Example**: Suppose an e-commerce platform is introducing a new feature involving changes to the product catalog. By creating a child branch specifically for this feature, developers can make modifications, test functionality, and iterate without impacting the main product catalog in the source branch until the feature is ready for deployment.

#### Key takeaways

- Connect **Creating Branches Overview** 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.

### Lesson 03 — Creating Branches

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

#### Lesson text

### **Creating Branches with API****Prerequisites:**

1.  **API Key and AuthToken:**
    
    Ensure you have the API key and [authtoken](https://www.contentstack.com/docs/developers/create-tokens/types-of-tokens#authentication-tokens-authtokens) for your Contentstack account.
    
2.  **Contentstack Stack API Endpoint:**
    
    Obtain the base API endpoint for your Contentstack stack.
    

## **Steps:**

### **1\. Authentication:**

Before making API calls, ensure you authenticate your requests by including the API key and authtoken in the headers.

Headers:  
Content-Type: application/json  
api\_key: YOUR\_API\_KEY  
authtoken : YOUR\_AUTH\_TOKEN  

### **2\. Get Existing Branches (Optional):**

You can retrieve information about existing branches in your Contentstack stack if needed.

GET /v3/stacks/branches

curl --location 'https://api.contentstack.io/v3/stacks/branches' \\  
  
\--header 'api\_key: \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*' \\  
  
\--header 'authtoken: \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*' \\  
  
\--header 'Content-Type: application/json' \\  
  
\--data ''

### **3\. Create a New Branch:**

To create a new branch, use the following API call:

POST /v3/stacks/branches

Request Body: {  
  
  "branch": {  
  
    "name": "NewBranchName",  
  
    "source": "SourceBranchID"  
  
  }  
  
}

*   Replace "NewBranchName" with the desired name for the new branch.
    

Replace "SourceBranchID" with the ID of the branch from which the new branch should inherit its data.  
  
  
curl --location 'https://api.contentstack.io/v3/stacks/branches' \\  
  
\--header 'Content-Type: application/json' \\  
  
\--header 'api\_key: \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*' \\  
  
\--header 'authtoken: \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*' \\  
  
\--header 'Content-Type: application/json' \\  
  
\--data '{  
  
    "branch": {  
  
        "uid": "dev",  
  
        "source": "main"  
  
    }  
  
}'

### **4\. Response:**

Upon successful creation, the response will include details about the new branch, including its unique ID.

{  
  
  "branch": {  
  
    "uid": "NEW\_BRANCH\_ID",  
  
    "name": "NewBranchName",  
  
    "source": "SourceBranchID",  
  
    // Other branch details...  
  
  }  
  
}  
  
  
{  
  
    "notice": "Your request to create branch is in progress. Please check organization bulk task queue for more details.",  
  
    "branch": {  
  
        "uid": "dev",  
  
        "source": "main",  
  
        "created\_by": "\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*",  
  
        "updated\_by": "\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*",  
  
        "created\_at": "2024-01-23T12:42:23.260Z",  
  
        "updated\_at": "2024-01-23T12:42:23.260Z",  
  
        "deleted\_at": "in-progress",  
  
        "alias": \[\]  
  
    }  
  
}

![branches-token.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/bltb75e380c0f638072/664d4eaa78533908439e4fac/branches-token.png)

### **5\. Error Handling:**

Handle errors by checking the status code and the response body. Common error responses include details about what went wrong.

### **6\. Conclusion:**

With these API calls, you can seamlessly integrate branch creation into your Contentstack workflows, facilitating efficient collaboration and content development.

## **Creating Branches Using CLI**

### **Prerequisites:**

1.  **Contentstack CLI:**
    
    *   Ensure you have the Contentstack CLI tool installed. You can install it from [https://www.contentstack.com/docs/developers/cli/install-the-cli](https://www.contentstack.com/docs/developers/cli/install-the-cli).
        
    
2.  **API Key:**
    
    *   Obtain the API key for your Contentstack stack.
        
    

### **Steps:**

### **1\. Configure CLI:**

Before initiating any commands, configure the Contentstack CLI tool with your API key, access token, and stack ID.

csdx auth:login

Follow the prompts to enter your API key, access token, and stack ID.

### **2\. Create a New Branch:**

Use the following command to create a new branch:

USAGE  
  $ csdx cm:branches:create  
  $ csdx cm:branches:create \[--source \] \[--uid \] \[-k \]  
  $ csdx cm:branches:create \[--source \] \[--uid \] \[--stack-api-key \]

FLAGS  
  -k, --stack-api-key=  Stack API key  
  --source=             Source branch from which new branch to be created  
  --uid=                Branch UID to be created

DESCRIPTION  
  Create a new branch

EXAMPLES  
  $ csdx cm:branches:create

  $ csdx cm:branches:create --source main -uid new\_branch -k bltxxxxxxxx

  $ csdx cm:branches:create --source main --uid new\_branch --stack-api-key bltxxxxxxxx

*   Replace new\_branch with the desired name for the new branch.
    
*   Replace source with the ID of the branch from which the new branch should inherit its data.
    
*   Provide API key value to -k or --stack-api-key
    

### 

![BranchesFoundations-L3-img-2.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt5ac58f90e15ecec3/67dc8839983a6519853b73d2/BranchesFoundations-L3-img-2.png)

### **3\. View Created Branch:**

Verify the successful creation of the branch by listing the existing branches:

List the branches

USAGE  
  $ csdx cm:branches

FLAGS  
  -k, --stack-api-key=  Stack API Key  
  --verbose                    Verbose

DESCRIPTION  
  List the branches

EXAMPLES  
  $ csdx cm:branches

  $ csdx cm:branches --verbose

  $ csdx cm:branches -k

This command will display a list of branches associated with your Contentstack stack, including the newly created branch.

![BranchesFoundations-L3-img-3.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/bltff9181c58c6a9665/67dc886545b229efcb910ded/BranchesFoundations-L3-img-3.png)

### **4\. Conclusion:**

Congratulations! You have successfully created a new branch in Contentstack using the CLI tool. This streamlined process allows for efficient management of content branches, fostering collaborative content development within your Contentstack environment.

# **Creating a Branch with the UI**

To delve into the intricacies of creating a new branch, users are required to navigate through the Contentstack interface and adhere to a structured set of steps:

1.  ## **Accessing Branch Settings:**
    
    *   Log in to your Contentstack account and proceed to the settings panel.
        
    *   Choose the "Branches" option to initiate the branch creation process.  
          
        
        ![BranchesFoundations-L3-img-4.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/bltc0d6b1880c4370b8/67dc888add73e3919fbf2be3/BranchesFoundations-L3-img-4.png)  
          
        
    
2.  ## **Initiating New Branch:**
    
    *   Within the Branches section, locate the "+ New Branch" option situated in the top-right corner.
        
    *   Click on this option to commence the creation of a fresh branch.  
          
        
        ![BranchesFoundations-L3-img-5.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt31eb048058c803d3/67dc88a398672543b08881e6/BranchesFoundations-L3-img-5.png)
        
    
3.  ## **Completing the Create New Branch Form:**
    
    *   Upon selecting to create a new branch, a prompt directs users to the "Create New Branch" form.
        
    *   Users are required to furnish the form with specific information to define the new branch.  
          
        
        ![BranchesFoundations-L3-img-6.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/bltf5c89f40d9347533/67dc88beb1a1f3c27c3ef06b/BranchesFoundations-L3-img-6.png)
        
    
4.  ## **Essential Information in the Create New Branch Form:**
    
    *   **Branch ID:** Users must assign a unique identifier to the branch, facilitating a clear distinction.
        
    *   **Source Selection:** From the provided dropdown menu, users must select the source branch from which the new branch will inherit its data.  
          
        ![BranchesFoundations-L3-img-7.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt99acc19d22f87666/67dc88d545b229e98e910df3/BranchesFoundations-L3-img-7.png)
        
    
5.  ## **Finalizing the Branch Creation:**
    
    *   To conclude the branch creation process, users are instructed to click the "Save" button in the form's bottom-right corner.
        
    

![BranchesFoundations-L3-img-8.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt765540af59682c04/67dc88f4037e2ba01b22d1b3/BranchesFoundations-L3-img-8.png)

![BranchesFoundations-L3-img-9.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blta7b764092858f5f6/67dc890df7eccc8c0490cfcd/BranchesFoundations-L3-img-9.png)

  

## **Further Reference**

*   [Creating a branch using API](https://www.contentstack.com/docs/developers/apis/content-management-api#create-a-branch)
    
*   [Creating a branch using CLI](https://www.contentstack.com/docs/developers/cli/compare-and-merge-branches-using-the-cli#create-a-branch)
    
*   [Listing Branches using CLI](https://www.contentstack.com/docs/developers/cli/compare-and-merge-branches-using-the-cli#list-branches)
    
*   [Creating a Branch using UI](https://www.contentstack.com/docs/developers/branches/create-a-branch)

#### Key takeaways

- Connect **Creating 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.

### Lesson 04 — Working with Branches | About Aliases

<!-- ai_metadata: {"lesson_id":"04","type":"text","duration_minutes":1,"topics":["Working","with","Branches","About","Aliases"]} -->

#### Lesson text

## **What are Aliases?**

Contentstack introduces a powerful feature allowing users to assign aliases to branches within their stack. These aliases serve as pointers, allowing an application to point directly to an alias instead of a branch.

Aliases offer a streamlined approach to front-end application development by providing an alternative means to reference branches. Developers can circumvent the need for extensive code modifications by defining a target branch for an alias. Moreover, aliases facilitate flexibility by enabling developers to redirect them to different target branches as needed, ensuring the application renders content from the specified branch.

For instance, consider a scenario where a stack incorporates a "production" alias, directing to the "main" branch. Contentstack automatically generates backups of the merged branch during merges for added safety. In case of any issues, redirect the "production" alias to the new "backup" branch, ensuring uninterrupted operations.

Effective management of aliases is essential for optimizing branch workflows. Users can conveniently manage their stack's aliases through the dedicated Aliases section, allowing seamless navigation and configuration.

## **Assign an Alias to a Branch**

An [Alias](https://www.contentstack.com/docs/developers/branches/about-aliases) helps point to a particular [branch](https://www.contentstack.com/docs/developers/branches/about-branches) in your stack. When your alias points to a specific branch, that branch acts as the primary branch from which you deliver content to your website. You can display the modifications made in this branch on your website without altering any code.

To create an alias, log in to your [Contentstack account](https://www.contentstack.com/login/), go to your [stack](https://www.contentstack.com/docs/developers/set-up-stack/about-stack), and perform the following steps:

1.  Click the “Settings” icon on the left navigation panel, select **Branches,** and click on the **Aliases** tab.
    
2.  Click on **\+ Assign Alias**.
    
    ![BranchesFoundations-L4-img-1.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/bltf3ae6fd09d0a4180/67dd7cef4a89c363a3a302d6/BranchesFoundations-L4-img-1.png)
    
3.  The **Assign New Alias** form appears for you to add the following details:
    
    *   **Alias ID:** Enter a name for the alias, such as “alias\_1,” “manager\_alias,” or so on.
        
    *   **Target Branch:** Select a branch you want your alias to point from the dropdown.
        
    
4.  Finally, click **Save** to save your alias.  
    
    ![BranchesFoundations-L4-img-2.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blteeed469e133f89c6/67dd7d09443bd66408f1cac0/BranchesFoundations-L4-img-2.png)
    

# **Edit an Alias**

Once created, you can edit an [alias](https://www.contentstack.com/docs/developers/branches/about-aliases) to make changes, such as edit the name and description, or change the target branch.

To edit an alias, log in to your [Contentstack account](https://app.contentstack.com/#!/login), go to your [stack](https://www.contentstack.com/docs/developers/set-up-stack/about-stack), and perform the following steps:

1.  Click the “Settings” icon on the left navigation panel, select **Branches,** and click on the **Aliases** tab.
    
2.  Hover over the alias you want to edit, and click on the “Edit” icon (pencil) that appears at the extreme right.![image.png](https://images.contentstack.io/v3/assets/blt23180bf2502c7444/bltd4b6c9e986ebe3b3/615a8198db34085ff954a01a/image.png)
    
3.  The **Edit Alias** form opens up, and you can also see the current target branch. Change the target branch to suit your needs.
    
    **Note:** Once you edit and assign the alias to another branch, it will stop pointing to the existing target branch and instead point to the newly selected target branch.
    
4.  After making the necessary changes, click **Save** to save your changes.
    
    **Note:** An Alias can point only to a single branch at a time.
    
    ![BranchesFoundations-L4-img-3.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/bltb0250e6a3d00cb61/67dd7d269867253c8c8889a4/BranchesFoundations-L4-img-3.png)
    

**Note:** The content from the new target branch can now be displayed on your website.

# **Deleting an Alias**

Contentstack allows you to delete an alias that you created in your [stack](https://www.contentstack.com/docs/developers/set-up-stack/about-stack).

**Note:** Unless you are the Owner or Admin of the stack, you cannot delete aliases created by other stakeholders.

To delete an alias, log in to your [Contentstack account](https://app.contentstack.com/#!/login), go to your stack, and perform the following steps:

1.  Click the “Settings” icon on the left navigation panel, select **Branches,** and click on the **Aliases** tab to view the list of available aliases.
    
2.  Hover over the alias you want to delete, click the “More Options” icon (three vertical dots) at the extreme right end, and select **Delete**.![image.png](https://images.contentstack.io/v3/assets/blt23180bf2502c7444/bltb2076ae6c5b6ab70/615a8202c22cd45706cf29d5/image.png)
    
3.  Type in your alias ID and confirm the **Delete** action.  
    ![Delete\_Branch.png](https://images.contentstack.io/v3/assets/blt23180bf2502c7444/blt97e38c2305ea7e51/62192f310e638750b44cd638/Delete_Branch.png)
    

**Warning:** These steps will permanently delete the alias.

  

## **Alias Operations using the API**

## **Get All Aliases**

The _get-all-aliases_ request returns comprehensive information about all the aliases available in a particular stack in your account.  
  
  
GET: https://api.contentstack.io/v3/stacks/branch\_aliases?limit={limit\_value}&skip={skip\_value}&include\_count={boolean\_value}

curl --location 'https://api.contentstack.io/v3/stacks/branch\_aliases' \\  
  
\--header 'api\_key: \*\*\*\*\*\*\*\*\*\*\*\*\*\*' \\  
  
\--header 'authorization: \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*' \\  
  
\--header 'Content-Type: application/json' \\  
  
\--data ''

Result

{  
  
    "branch\_aliases": \[  
  
        {  
  
            "uid": "dev",  
  
            "source": "main",  
  
            "created\_by": "\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*",  
  
            "updated\_by": "\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*",  
  
            "created\_at": "2024-02-01T07:34:54.356Z",  
  
            "updated\_at": "2024-02-01T07:36:52.330Z",  
  
            "deleted\_at": false,  
  
            "alias": "dev\_alias"  
  
        },  
  
        {  
  
            "uid": "main",  
  
            "source": "",  
  
            "created\_by": "\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*",  
  
            "updated\_by": "\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*",  
  
            "created\_at": "2023-12-01T07:04:10.294Z",  
  
            "updated\_at": "2024-02-01T07:36:21.706Z",  
  
            "deleted\_at": false,  
  
            "alias": "main\_alias"  
  
        },  
  
        {  
  
            "uid": "staging",  
  
            "source": "main",  
  
            "created\_by": "\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*",  
  
            "updated\_by": "\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*",  
  
            "created\_at": "2024-02-01T07:33:22.139Z",  
  
            "updated\_at": "2024-02-01T07:37:06.284Z",  
  
            "deleted\_at": false,  
  
            "alias": "stage\_alias"  
  
        }  
  
    \]  
  
}

![BranchesFoundations-L4-img-6.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt1505b71823069981/67dd7d579867252c408889b4/BranchesFoundations-L4-img-6.png)

## **Get a Single Alias**

The _get-a-single-alias_ request returns information about a specific alias.

GET: https://api.contentstack.io/v3/stacks/branch\_aliases/{branch\_alias\_uid}

  
curl --location 'https://api.contentstack.io/v3/stacks/branch\_aliases/main\_alias' \\  
  
\--header 'api\_key: \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*' \\  
  
\--header 'authorization: \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*' \\  
  
\--header 'Content-Type: application/json' \\  
  
\--data ''

  

Result :  
  
{  
  
    "branch\_alias": {  
  
        "uid": "main",  
  
        "source": "",  
  
        "created\_by": "\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*",  
  
        "updated\_by": "\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*",  
  
        "created\_at": "2023-12-01T07:04:10.294Z",  
  
        "updated\_at": "2024-02-01T07:36:21.706Z",  
  
        "deleted\_at": false,  
  
        "alias": "main\_alias"  
  
    }  
  
}

![BranchesFoundations-L4-img-7.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/bltac3fd31b34a7265e/67dd7d71c9b8d44ac6d141c1/BranchesFoundations-L4-img-7.png)

## **Assign an Alias**

The _assign-an-alias_ request creates a new alias in a particular stack of your organization. This alias can point to your stack's existing branch (target branch).

**Note:** Only stack owners, admins, and developers can assign a new alias to a branch. You must only use the authtoken to assign an alias.

PUT: https://api.contentstack.io/v3/stacks/branch\_aliases/{branch\_alias\_uid}  
  
  
curl --location --request PUT 'https://api.contentstack.io/v3/stacks/branch\_aliases/dev\_alias' \\  
  
\--header 'Content-Type: application/json' \\  
  
\--header 'api\_key: \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*' \\  
  
\--header 'authtoken: \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*' \\  
  
\--header 'Content-Type: application/json' \\  
  
\--data '{  
  
    "branch\_alias": {  
  
        "target\_branch": "dev"  
  
    }  
  
}'  
  
  
Result 

{  
  
    "notice": "Branch alias assigned successfully.",  
  
    "branch\_alias": {  
  
        "uid": "dev",  
  
        "source": "main",  
  
        "created\_by": "\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*",  
  
        "updated\_by": "\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*",  
  
        "created\_at": "2024-02-01T07:34:54.356Z",  
  
        "updated\_at": "2024-02-01T09:05:02.160Z",  
  
        "deleted\_at": false,  
  
        "alias": "dev\_alias"  
  
    }  
  
}

![BranchesFoundations-L4-img-8.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt7765245e272b64d8/67dd7d8bc566eed34c5e0055/BranchesFoundations-L4-img-8.png)

## **Delete an Alias**

The delete-an-alias request deletes an existing alias.

To confirm the deletion of an alias, you need to specify the force=true query parameter.

When executing the API call, provide the UID of your alias in the “URL Parameters” section.

**Note**: You must only use the authtoken to delete an alias.  
  
  
DELETE: https://api.contentstack.io/v3/stacks/branch\_aliases/{branch\_alias\_uid}?force={boolean\_value}  
  
  
curl --location --request DELETE 'https://api.contentstack.io/v3/stacks/branch\_aliases/dev\_alias?force=true' \\  
  
\--header 'api\_key: \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*' \\  
  
\--header 'authtoken: \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*' \\  
  
\--header 'Content-Type: application/json' \\  
  
\--data ''

Result

{  
  
    "notice": "Branch alias deleted successfully."  
  
}

![BranchesFoundations-L4-img-9.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt62c1befbeedc4d9c/67dd7da23a0f38dd4a00eac8/BranchesFoundations-L4-img-9.png)

  

# **Alias Operations using the API**

## **Get All Aliases**

The _get-all-aliases_ request returns comprehensive information about all the aliases available in a particular stack in your account.  
  
  
GET: https://api.contentstack.io/v3/stacks/branch\_aliases?limit={limit\_value}&skip={skip\_value}&include\_count={boolean\_value}

curl --location 'https://api.contentstack.io/v3/stacks/branch\_aliases' \\  
  
\--header 'api\_key: \*\*\*\*\*\*\*\*\*\*\*\*\*\*' \\  
  
\--header 'authorization: \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*' \\  
  
\--header 'Content-Type: application/json' \\  
  
\--data ''

Result

{  
  
    "branch\_aliases": \[  
  
        {  
  
            "uid": "dev",  
  
            "source": "main",  
  
            "created\_by": "\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*",  
  
            "updated\_by": "\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*",  
  
            "created\_at": "2024-02-01T07:34:54.356Z",  
  
            "updated\_at": "2024-02-01T07:36:52.330Z",  
  
            "deleted\_at": false,  
  
            "alias": "dev\_alias"  
  
        },  
  
        {  
  
            "uid": "main",  
  
            "source": "",  
  
            "created\_by": "\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*",  
  
            "updated\_by": "\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*",  
  
            "created\_at": "2023-12-01T07:04:10.294Z",  
  
            "updated\_at": "2024-02-01T07:36:21.706Z",  
  
            "deleted\_at": false,  
  
            "alias": "main\_alias"  
  
        },  
  
        {  
  
            "uid": "staging",  
  
            "source": "main",  
  
            "created\_by": "\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*",  
  
            "updated\_by": "\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*",  
  
            "created\_at": "2024-02-01T07:33:22.139Z",  
  
            "updated\_at": "2024-02-01T07:37:06.284Z",  
  
            "deleted\_at": false,  
  
            "alias": "stage\_alias"  
  
        }  
  
    \]  
  
}

![BranchesFoundations-L4-img-10.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt8b262655ba906d61/67dd7dbadd73e3fa86bf347b/BranchesFoundations-L4-img-10.png)

## **Get a Single Alias**

The _get-a-single-alias_ request returns information about a specific alias.

GET: https://api.contentstack.io/v3/stacks/branch\_aliases/{branch\_alias\_uid}

  
curl --location 'https://api.contentstack.io/v3/stacks/branch\_aliases/main\_alias' \\  
  
\--header 'api\_key: \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*' \\  
  
\--header 'authorization: \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*' \\  
  
\--header 'Content-Type: application/json' \\  
  
\--data ''

  

Result :  
  
{  
  
    "branch\_alias": {  
  
        "uid": "main",  
  
        "source": "",  
  
        "created\_by": "\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*",  
  
        "updated\_by": "\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*",  
  
        "created\_at": "2023-12-01T07:04:10.294Z",  
  
        "updated\_at": "2024-02-01T07:36:21.706Z",  
  
        "deleted\_at": false,  
  
        "alias": "main\_alias"  
  
    }  
  
}

![BranchesFoundations-L4-img-11.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/bltbcb81879dc42412b/67dd7dd35e486d801571b55c/BranchesFoundations-L4-img-11.png)

## **Assign an Alias**

The _assign-an-alias_ request creates a new alias in a particular stack of your organization. This alias can point to your stack's existing branch (target branch).

**Note:** Only stack owners, admins, and developers can assign a new alias to a branch. You must only use the authtoken to assign an alias.

PUT: https://api.contentstack.io/v3/stacks/branch\_aliases/{branch\_alias\_uid}  
  
  
curl --location --request PUT 'https://api.contentstack.io/v3/stacks/branch\_aliases/dev\_alias' \\  
  
\--header 'Content-Type: application/json' \\  
  
\--header 'api\_key: \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*' \\  
  
\--header 'authtoken: \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*' \\  
  
\--header 'Content-Type: application/json' \\  
  
\--data '{  
  
    "branch\_alias": {  
  
        "target\_branch": "dev"  
  
    }  
  
}'  
  
  
Result 

{  
  
    "notice": "Branch alias assigned successfully.",  
  
    "branch\_alias": {  
  
        "uid": "dev",  
  
        "source": "main",  
  
        "created\_by": "\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*",  
  
        "updated\_by": "\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*",  
  
        "created\_at": "2024-02-01T07:34:54.356Z",  
  
        "updated\_at": "2024-02-01T09:05:02.160Z",  
  
        "deleted\_at": false,  
  
        "alias": "dev\_alias"  
  
    }  
  
}

![BranchesFoundations-L4-img-12.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt8b6ba3c18e1f4be7/67dd7ded37e25a6feb1e460d/BranchesFoundations-L4-img-12.png)

## **Delete an Alias**

The delete-an-alias request deletes an existing alias.

To confirm the deletion of an alias, you need to specify the force=true query parameter.

When executing the API call, provide the UID of your alias in the “URL Parameters” section.

**Note**: You must only use the authtoken to delete an alias.  
  
  
DELETE: https://api.contentstack.io/v3/stacks/branch\_aliases/{branch\_alias\_uid}?force={boolean\_value}  
  
  
curl --location --request DELETE 'https://api.contentstack.io/v3/stacks/branch\_aliases/dev\_alias?force=true' \\  
  
\--header 'api\_key: \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*' \\  
  
\--header 'authtoken: \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*' \\  
  
\--header 'Content-Type: application/json' \\  
  
\--data ''

Result

{  
  
    "notice": "Branch alias deleted successfully."  
  
}

![BranchesFoundations-L4-img-13.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt32c546a9f855b8d3/67dd7e0498672522078889c2/BranchesFoundations-L4-img-13.png)

  

### **Further Reference**

*   [Assigning an alias to a branch](https://www.contentstack.com/docs/developers/branches/assign-an-alias-to-a-branch)
    
*   [Editing an Alias](https://www.contentstack.com/docs/developers/branches/edit-an-alias)
    
*   [Deleting an Alias](https://www.contentstack.com/docs/developers/branches/delete-an-alias)
    
*   [Get all Aliase](https://www.contentstack.com/docs/developers/apis/content-management-api#get-all-aliases)[s using API](https://www.contentstack.com/docs/developers/apis/content-management-api#get-all-aliases)
    
*   [Get a single alias](https://www.contentstack.com/docs/developers/apis/content-management-api#get-a-single-alias) [using API](https://www.contentstack.com/docs/developers/apis/content-management-api#get-a-single-alias)
    
*   [Assigning an alias](https://www.contentstack.com/docs/developers/apis/content-management-api#assign-an-alias) [using API](https://www.contentstack.com/docs/developers/apis/content-management-api#assign-an-alias)
    
*   [Deleting an alias](https://www.contentstack.com/docs/developers/apis/content-management-api#delete-an-alias) [using API](https://www.contentstack.com/docs/developers/apis/content-management-api#delete-an-alias)

#### Key takeaways

- Connect **Working with Branches | About Aliases** 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.

### Lesson 05 — Deleting a Branch

<!-- ai_metadata: {"lesson_id":"05","type":"text","duration_minutes":1,"topics":["Deleting","Branch"]} -->

#### Lesson text

# **Deleting Branches Using the CLI**

## **1\. Identify the Branch ID:**

Retrieve the ID of the branch you want to delete.

## **2\. Use the CLI Command:**

Delete a branch

USAGE  
  $ csdx cm:branches:delete \[-uid \] \[-k \]  
  $ csdx cm:branches:delete \[--uid \] \[--stack-api-key \]

FLAGS  
  -k, --stack-api-key=  Stack API key  
  -y, --yes                    Force the deletion of the branch by skipping the confirmation  
  --uid=                Branch UID to be deleted

DESCRIPTION  
  Delete a branch

EXAMPLES  
  $ csdx cm:branches:delete

  $ csdx cm:branches:delete --uid main -k bltxxxxxxxx

  $ csdx cm:branches:delete --uid main --stack-api-key bltxxxxxxxx

  $ csdx cm:branches:delete --uid main --stack-api-key bltxxxxxxxx --yes

![BranchesFoundations-L5-img-1.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt78563255bd9268cc/67dd7e810c6f5553861fcef1/BranchesFoundations-L5-img-1.png)

## **3\. Verify Deletion:**

Confirm the successful deletion by checking the list of branches or using the appropriate CLI command to list branches.

csdx cm:branches -k

![BranchesFoundations-L5-img-2.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt667ca21ead42a562/67dd7ea2c5b83e650e924b8e/BranchesFoundations-L5-img-2.png)

## **Conclusion:**

Following these step-by-step instructions, you can seamlessly delete branches in Contentstack using the CLI tool.  

# **Deleting Branches Using API Calls**

## **1\. Identify API Key and authtoken and Branch ID:**

*   Obtain the API KEY of the stack for the branch you wish to delete.
    
*   Obtain the authtoken for the user.
    
*   Obtain the unique ID of the branch you wish to delete.
    

## **2\. Make API Call:**

DELETE /v3/stacks/branches/{branch\_id}

Replace {branch\_id} with the ID of the branch you want to delete.  
  
  
curl --location --request DELETE 'https://api.contentstack.io/v3/stacks/branches/dev?force=true' \\  
  
\--header 'api\_key: \*\*\*\*\*\*\*\*\*\*\*\*\*\*' \\  
  
\--header 'authtoken: \*\*\*\*\*\*\*\*\*\*\*\*\*' \\  
  
\--header 'Content-Type: application/json' \\  
  
\--data ''

## **3\. Response:**

Upon successful deletion, the response will confirm the removal of the specified branch.

{  
  
    "notice": "Your request to delete branch is in progress. Please check organization bulk task queue for more details.",  
  
    "branch": {  
  
        "uid": "dev",  
  
        "source": "main",  
  
        "created\_by": "\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*",  
  
        "updated\_by": "\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*",  
  
        "created\_at": "2024-01-23T09:13:09.739Z",  
  
        "updated\_at": "2024-01-23T09:13:10.714Z",  
  
        "deleted\_at": false,  
  
        "alias": \[\]  
  
    }  
  
}

![BranchesFoundations-L5-img-3.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/bltc2f10243ea60bd3f/67dd7ebbc566ee10565e0075/BranchesFoundations-L5-img-3.png)

# **Deleting Branches Using UI**

## **1\. Navigate to Branch Settings:**

*   Log in to your Contentstack account.
    
*   Access the settings panel.
    
*   Choose "Branches" to view a list of existing branches.  
      
    ![BranchesFoundations-L5-img-4.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt0c0aed4460902b62/67dd7ed3983a65c6393b7c44/BranchesFoundations-L5-img-4.png)
    

## **2\. Select Branch for Deletion:**

*   Locate the branch you want to delete from the list.
    
*   Click on the branch to select it.  
      
    ![BranchesFoundations-L5-img-5.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/bltf713e8213a26cb19/67dd7ee9782bfb67eb6f5634/BranchesFoundations-L5-img-5.png)
    

## **3\. Delete Branch:**

*   Once the branch is selected, look for the option to delete the branch (usually represented by a trash/bin icon).
    
*   Confirm the deletion when prompted.  
      
    
    ![BranchesFoundations-L5-img-6.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/bltdba319de396dc790/67dd7efe0c6f5566621fcf14/BranchesFoundations-L5-img-6.png)  
      
    
    ![BranchesFoundations-L5-img-7.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blte6fc933625df28b1/67dd7f134a89c3933aa3030b/BranchesFoundations-L5-img-7.png)  
      
    
    ![BranchesFoundations-L5-img-8.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt36345100a21a082c/67dd7f36782bfb67156f5641/BranchesFoundations-L5-img-8.png)
    

# **Further Reference**

*   [Deleting a branch](https://www.contentstack.com/docs/developers/branches/delete-a-branch) [using CLI](https://www.contentstack.com/docs/developers/branches/delete-a-branch)
    
*   [Deleting a branch using API](https://www.contentstack.com/docs/developers/apis/content-management-api#delete-a-branch)
    
*   [Deleting a branch using UI](https://www.contentstack.com/docs/developers/branches/delete-a-branch)

#### Key takeaways

- Connect **Deleting a Branch** 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.

### Lesson 06 — Comparing Branches

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

#### Lesson text

## **Introduction**

In Contentstack, the Branch Compare feature allows users to analyze the differences between two branches: the Base branch (typically 'main') and the Compare branch (where desired changes are made). This comparison serves to understand changes before merging them into the base branch.

## **Methods of Comparison**

When comparing branches, users can view differences in:  
\- Content types and global fields  
\- Specific content types  
\- Specific global fields

## **Comparison Status:**

Three outcomes are possible:  
**1\. Base only**: _base only notifies that a particular content type or global field is present only in the base branch and is not present in the compare branch_.  
**2\. Compare only:** _compare only notifies that a particular content type or global field is present only in the compare branch and is not present in the base branch_.  
**3\. Modified:** The item exists in both branches but has been altered.

## **Use Cases:**

**1\. Modifying a Content Type:**  
\- Scenario: Altering fields without impacting the source branch.  
\- Approach: Create a child branch inheriting from the main branch, make changes, and then compare.  
\- Status: Differences are marked as "modified."

We are going to modify the fields present in the **Author** content type.  
Let's first see the structure of the Author content type in the source branch i.e., in the **main branch.**

![BranchesFoundations-L6-img-1.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/bltad81e23580acf738/67dd7f9bf7eccc607890d8af/BranchesFoundations-L6-img-1.png)

We will change field names **First Name to Author First Name** and **Last Name to Author Last Name** in the compare branch i.e., **dev branch**.

  

Also, we are going to change the field from **SEO Global field**

Let's first see the structure of the SEO Global field  in the source branch i.e., in the main branch

![BranchesFoundations-L6-img-2.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt830e2f5390decd80/67dd7fc3339f292cd78b60dd/BranchesFoundations-L6-img-2.png)

We changed the **Meta Title filed to the SEO Meta Title** in the **dev** branch.

![BranchesFoundations-L6-img-3.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blte59d7f5914a6c4bd/67dd7fd9b1a1f361133ef8aa/BranchesFoundations-L6-img-3.png)

**2\. Adding a New Feature:**  
\- Scenario: Introducing a new content type.  
\- Approach: Create a new branch, make changes, and then compare with the main branch.  
\- Status: Differences are marked as "compare only" if the new content type is only in the compare branch.

We are going to add a new content type named "**Branch Demo**" in the **dev branch**

![BranchesFoundations-L6-img-4.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt3da3b2c03699be5f/67dd7fed6f68581be5fda869/BranchesFoundations-L6-img-4.png)

  

![BranchesFoundations-L6-img-5.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt3ec2aee61550fa99/67dd8005efd8a9099c4c00e5/BranchesFoundations-L6-img-5.png)

Now let's do the comparison by using Content Management API as well as CLI

**First will see all compare operations with API**  
**1)**  **Compare branch**

curl --location 'https://api.contentstack.io/v3/stacks/branches\_compare?compare\_branch=dev'

\\ --header 'api\_key: \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*'

\\ --header 'authorization: \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*'

\\ --header 'Content-Type: application/json'

\\ --data ''

  

**Result**

{  
  
    "branches": {  
  
        "base\_branch": "main",  
  
        "compare\_branch": "dev"  
  
    },  
  
    "diff": \[  
  
        {  
  
            "title": "SEO",  
  
            "uid": "seo",  
  
            "type": "global\_field",  
  
            "status": "modified"  
  
        },  
  
        {  
  
            "title": "Branch Demo",  
  
            "uid": "branch\_demo",  
  
            "type": "content\_type",  
  
            "status": "compare\_only"  
  
        },  
  
        {  
  
            "title": "Author",  
  
            "uid": "author",  
  
            "type": "content\_type",  
  
            "status": "modified"  
  
        }  
  
    \]  
  
}

![BranchesFoundations-L6-img-6.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/bltee56270033ba97d1/67dd801a17f7b4915d0d0173/BranchesFoundations-L6-img-6.png)

**2) Compare Content Type between Branches**

curl --location 'https://api.contentstack.io/v3/stacks/branches\_compare/content\_types?compare\_branch=dev' \\  
\--header 'api\_key: \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*' \\  
\--header 'authorization: \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*' \\  
\--header 'Content-Type: application/json' \\  
\--data ''

**Result**

{  
  
    "branches": {  
  
        "base\_branch": "main",  
  
        "compare\_branch": "dev"  
  
    },  
  
    "diff": \[  
  
        {  
  
            "title": "Branch Demo",  
  
            "uid": "branch\_demo",  
  
            "type": "content\_type",  
  
            "status": "compare\_only"  
  
        },  
  
        {  
  
            "title": "Author",  
  
            "uid": "author",  
  
            "type": "content\_type",  
  
            "status": "modified"  
  
        }  
  
    \]  
  
}

## 

![BranchesFoundations-L6-img-7.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blta26e739a070f547b/67dd80330c6f5559d01fcf28/BranchesFoundations-L6-img-7.png)

**3) Compare Global Fields between Branches**

curl --location 'https://api.contentstack.io/v3/stacks/branches\_compare/global\_fields?compare\_branch=dev' \\  
\--header 'api\_key: \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*' \\  
\--header 'authorization: \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*' \\  
\--header 'Content-Type: application/json' \\  
\--data ''

**Result**

{  
  
    "branches": {  
  
        "base\_branch": "main",  
  
        "compare\_branch": "dev"  
  
    },  
  
    "diff": \[  
  
        {  
  
            "title": "SEO",  
  
            "uid": "seo",  
  
            "type": "global\_field",  
  
            "status": "modified"  
  
        }  
  
    \]  
  
}

![BranchesFoundations-L6-img-8.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blte1bde4be421df008/67dd80495e486d5c7371b5a5/BranchesFoundations-L6-img-8.png)

**4) Compare Specific Content Types between Branches**

curl --location 'https://api.contentstack.io/v3/stacks/branches\_compare/content\_types/author?compare\_branch=dev' \\  
\--header 'api\_key: \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*' \\  
\--header 'authorization: \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*' \\  
\--header 'Content-Type: application/json' \\  
\--data ''

**Result**

{  
  
    "branches": {  
  
        "base\_branch": "main",  
  
        "compare\_branch": "dev"  
  
    },  
  
    "diff": {  
  
        "uid": "author",  
  
        "type": "content\_type",  
  
        "status": "modified",  
  
        "base\_branch": {  
  
            "differences": \[  
  
                {  
  
                    "display\_name": "First Name",  
  
                    "uid": "title",  
  
                    "data\_type": "text",  
  
                    "mandatory": true,  
  
                    "unique": true,  
  
                    "field\_metadata": {  
  
                        "\_default": true,  
  
                        "version": 3  
  
                    },  
  
                    "multiple": false,  
  
                    "non\_localizable": false,  
  
                    "indexed": false,  
  
                    "inbuilt\_model": false,  
  
                    "path": "schema\[0\]"  
  
                },  
  
                {  
  
                    "data\_type": "text",  
  
                    "display\_name": "Last Name",  
  
                    "uid": "last\_name",  
  
                    "field\_metadata": {  
  
                        "description": "",  
  
                        "default\_value": "",  
  
                        "version": 3  
  
                    },  
  
                    "format": "",  
  
                    "error\_messages": {  
  
                        "format": ""  
  
                    },  
  
                    "mandatory": false,  
  
                    "multiple": false,  
  
                    "non\_localizable": false,  
  
                    "unique": false,  
  
                    "indexed": false,  
  
                    "inbuilt\_model": false,  
  
                    "path": "schema\[1\]"  
  
                }  
  
            \],  
  
            "schema": null  
  
        },  
  
        "compare\_branch": {  
  
            "differences": \[  
  
                {  
  
                    "display\_name": "Author First Name",  
  
                    "uid": "title",  
  
                    "data\_type": "text",  
  
                    "mandatory": true,  
  
                    "unique": true,  
  
                    "field\_metadata": {  
  
                        "\_default": true,  
  
                        "version": 3  
  
                    },  
  
                    "multiple": false,  
  
                    "non\_localizable": false,  
  
                    "indexed": false,  
  
                    "inbuilt\_model": false,  
  
                    "path": "schema\[0\]"  
  
                },  
  
                {  
  
                    "data\_type": "text",  
  
                    "display\_name": "Author Last Name",  
  
                    "uid": "last\_name\_dev",  
  
                    "field\_metadata": {  
  
                        "description": "",  
  
                        "default\_value": "",  
  
                        "version": 3  
  
                    },  
  
                    "format": "",  
  
                    "error\_messages": {  
  
                        "format": ""  
  
                    },  
  
                    "mandatory": false,  
  
                    "multiple": false,  
  
                    "non\_localizable": false,  
  
                    "unique": false,  
  
                    "indexed": false,  
  
                    "inbuilt\_model": false,  
  
                    "path": "schema\[1\]"  
  
                }  
  
            \],  
  
            "schema": null  
  
        }  
  
    }  
  
}

![BranchesFoundations-L6-img-9.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/bltf5233f1e1a241292/67dd80686f68581895fda877/BranchesFoundations-L6-img-9.png)

**5) Compare Specific Global Fields between Branches**

curl --location 'https://api.contentstack.io/v3/stacks/branches\_compare/global\_fields/seo?compare\_branch=dev' \\  
\--header 'api\_key: \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*' \\  
\--header 'authorization: \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*' \\  
\--header 'Content-Type: application/json' \\  
\--data ''

**Result**

{  
  
    "branches": {  
  
        "base\_branch": "main",  
  
        "compare\_branch": "dev"  
  
    },  
  
    "diff": {  
  
        "uid": "seo",  
  
        "type": "global\_field",  
  
        "status": "modified",  
  
        "base\_branch": {  
  
            "differences": \[  
  
                {  
  
                    "data\_type": "text",  
  
                    "display\_name": "Meta Title",  
  
                    "uid": "meta\_title",  
  
                    "field\_metadata": {  
  
                        "description": "",  
  
                        "default\_value": "",  
  
                        "version": 3  
  
                    },  
  
                    "format": "",  
  
                    "error\_messages": {  
  
                        "format": ""  
  
                    },  
  
                    "multiple": false,  
  
                    "mandatory": false,  
  
                    "unique": false,  
  
                    "non\_localizable": false,  
  
                    "indexed": false,  
  
                    "inbuilt\_model": false,  
  
                    "path": "schema\[0\]"  
  
                }  
  
            \],  
  
            "schema": null  
  
        },  
  
        "compare\_branch": {  
  
            "differences": \[  
  
                {  
  
                    "data\_type": "text",  
  
                    "display\_name": "SEO Meta Title",  
  
                    "uid": "meta\_title",  
  
                    "field\_metadata": {  
  
                        "description": "",  
  
                        "default\_value": "",  
  
                        "version": 3  
  
                    },  
  
                    "format": "",  
  
                    "error\_messages": {  
  
                        "format": ""  
  
                    },  
  
                    "multiple": false,  
  
                    "mandatory": false,  
  
                    "unique": false,  
  
                    "non\_localizable": false,  
  
                    "indexed": false,  
  
                    "inbuilt\_model": false,  
  
                    "path": "schema\[0\]"  
  
                }  
  
            \],  
  
            "schema": null  
  
        }  
  
    }  
  
}

## 

![BranchesFoundations-L6-img-10.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt870a0938f973914f/67dd80830c6f555c231fcf32/BranchesFoundations-L6-img-10.png)

### **Now let's see all compare operations using the Command Line Interface (CLI)**  

The comparison results are distinguished based on the following:

1.  A “+” symbol with green highlighted text: Indicates that this is present only in the compare branch.
    
2.  A “±” symbol with blue highlighted text Indicates that this is present in both branches but has different values.
    
3.  A “-” symbol with red highlighted text: Indicates that this is not present in the compare branch.
    

  

csdx cm:branches:diff --help  
Differences between two branches

USAGE  
  $ csdx cm:branches:diff \[--base-branch \] \[--compare-branch \] \[-k \]\[--module \]

FLAGS  
  -k, --stack-api-key=  Provide Stack API key to show difference between branches  
  --base-branch=        Base branch  
  --compare-branch=     Compare branch  
  --format=            \[default: compact-text\] \[Optional\] Type of flags to show branches differences  
  
  --module=            Module  

DESCRIPTION  
  Differences between two branches

EXAMPLES  
  $ csdx cm:branches:diff

  $ csdx cm:branches:diff --stack-api-key "bltxxxxxxxx"

  $ csdx cm:branches:diff --compare-branch "dev"

  $ csdx cm:branches:diff --compare-branch "dev" --stack-api-key "bltxxxxxxxx"

  $ csdx cm:branches:diff --compare-branch "dev" --module "content-types"

  $ csdx cm:branches:diff --module "content-types" --format "detailed-text"

  $ csdx cm:branches:diff --compare-branch "dev" --format "detailed-text"

  $ csdx cm:branches:diff --stack-api-key "bltxxxxxxxx" --base-branch "main"

  $ csdx cm:branches:diff --stack-api-key "bltxxxxxxxx" --base-branch "main" --compare-branch "dev"

  $ csdx cm:branches:diff --stack-api-key "bltxxxxxxxx" --base-branch "main" --module "content-types"

  $ csdx cm:branches:diff --stack-api-key "bltxxxxxxxx" --base-branch "main" --compare-branch "dev" --module "content-types"

  $ csdx cm:branches:diff --stack-api-key "bltxxxxxxxx" --base-branch "main" --compare-branch "dev" --module "content-types" --format "detailed-text"

**1) Get all module's difference**

![BranchesFoundations-L6-img-11.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt4363c1710c1de892/67dd809c6f685822d2fda882/BranchesFoundations-L6-img-11.png)

**2) Get all content types difference**

![BranchesFoundations-L6-img-12.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt0f4254e5752bbc4d/67dd80bb20a3dcd689f8285e/BranchesFoundations-L6-img-12.png)

**3) Get all global fields' difference**

![BranchesFoundations-L6-img-13.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt6724b3e928297c65/67dd80d9460eb4086594780c/BranchesFoundations-L6-img-13.png)

## **Conclusion:**

Comparing branches in Contentstack facilitates safe development and integration of changes, allowing users to manage modifications effectively before merging them into the main branch.

  

# **Further Reference**

*   [Compare branches](https://www.contentstack.com/docs/developers/apis/content-management-api#compare-branches)
    
*   [Compare Content Types between branches](https://www.contentstack.com/docs/developers/apis/content-management-api#compare-content-types-between-branches)
    
*   [Compare Global Fields between branches](https://www.contentstack.com/docs/developers/apis/content-management-api#compare-global-fields-between-branches)
    
*   [Compare specific Content Type between branches](https://www.contentstack.com/docs/developers/apis/content-management-api#compare-specific-content-type-between-branches)
    
*   [Compare specific Global Fields between branches](https://www.contentstack.com/docs/developers/apis/content-management-api#compare-specific-global-field-between-branches)
    
*   [Steps to compare branches](https://www.contentstack.com/docs/developers/cli/compare-and-merge-branches-using-the-cli#steps-to-compare-branches)

#### Key takeaways

- Connect **Comparing 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.

### Lesson 07 — Merging Branches

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

### Lesson 08 — Environments and Branches

<!-- ai_metadata: {"lesson_id":"08","type":"text","duration_minutes":1,"topics":["Environments","and","Branches"]} -->

#### Lesson text

## **Environments**

An environment in Contentstack refers to the content delivery destination where you publish and deploy the entries of your application or website.

When you create an environment, it acts as a target for publishing your content. For example, you might have separate development, staging, and production environments.

Environments allow you to manage different deployment scenarios and ensure your content reaches the right place.

[Note: When working within branches, any environment created within a branch will be available across all the other branches of the stack](https://www.contentstack.com/docs/developers/set-up-environments/add-an-environment).  

## **Branches**

Branches enable you to manage your work effectively by separating “in-progress” work from live and stable jobs in the production environment.

Instead of working sequentially, teams can work in parallel using branches, which is especially beneficial in aiming for higher release velocity.

Changes made within different branches do not affect the main branch, allowing for isolated development and testing.

[In summary, branches facilitate collaboration, version control, and streamlined workflows within your Contentstack project](https://www.contentstack.com/blog/product-updates/management-development-workflows-branches).

  
**1\. Environments for Content Preview on UAT:**  
   - **Purpose**: Environments serve as staging areas where content changes can be previewed before they are deployed to the live production environment. The UAT (User Acceptance Testing) instance, in particular, allows stakeholders to review and validate content updates, ensuring they meet the desired standards and do not introduce any issues.  
   - **Workflow**: Content changes are first implemented and tested in a preview environment. Once validated, they are promoted to the UAT environment for further scrutiny. Stakeholders such as content editors, quality assurance teams, and project managers can access the UAT instance to preview the changes and provide feedback. After any necessary adjustments, the approved changes are finally deployed to the live production environment.  
   - **Benefits**: Using environments for content preview on UAT helps minimize the risk of introducing errors or inconsistencies to the live site. It provides a controlled environment for testing and validation, allowing stakeholders to ensure that the content changes align with business requirements and user expectations before they go live.  
**2.** **Branches for CI/CD in Content Modeling**:  
   - **Purpose**: Branches are utilized within a CI/CD (Continuous Integration/Continuous Deployment) process to facilitate collaborative content modeling and integration changes. Developers create separate branches, such as a Dev branch, to work on specific features or updates without affecting the main production environment.  
   - **Workflow**: Developers start by creating a Dev branch from the existing setup. They then implement content modeling changes, integration enhancements, and other modifications within this isolated environment. Automated testing and manual validation ensure the changes meet quality standards and do not disrupt existing functionality. Once validated, the changes are merged into the main branch, where the live editorial team can review and approve them for deployment to the production environment.  
   - **Benefits**: Branches streamline content development by providing a structured approach to managing changes. They enable developers to work independently on different features or enhancements, reducing the risk of conflicts and allowing for parallel development efforts. By incorporating CI/CD practices, teams can ensure faster and more reliable deployments of content types change updates.  
**3\. Environments for Content Segregation:**  
   - **Purpose**: Environments can be leveraged to segregate content based on specific use cases or platform requirements. For example, organizations may need to deliver platform-specific content tailored for mobile and web environments. Creating separate environments associated with each platform allows content to be managed and delivered independently, ensuring a consistent and optimized user experience across different channels.  
   - **Workflow**: Content authors create and manage platform-specific content within designated environments, each configured with its delivery token. This token is used to authenticate requests and ensure content is delivered to the appropriate platform. Content segregation allows for granular control over content distribution, enabling organizations to tailor content strategies and optimize engagement based on the characteristics of each platform.  
   - **Benefits**: Utilizing environments for content segregation enables organizations to manage and deliver platform-specific content effectively. It supports targeted content delivery, enhances user engagement, and simplifies content management workflows by providing dedicated environments for each platform-specific use case.

#### Key takeaways

- Connect **Environments and 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.

### Lesson 09 — Case Studies With Branches

<!-- ai_metadata: {"lesson_id":"09","type":"text","duration_minutes":1,"topics":["Case","Studies","With","Branches"]} -->

#### Lesson text

# **Blue-Green Deployment with Branches** (**CI CD Automation & Branch Strategy)**

**Context**

The idea here, or the use case, rather, is to be able to somehow streamline the development process both from a content management perspective as well as from a front-end perspective (code) and to be able to automate most of it

**Proposed Branching Strategy**

![BranchesFoundations-L9-img-1.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt80669c6c79b6ff1f/67dd863ac5b83eaf0b924c25/BranchesFoundations-L9-img-1.png)

**CI CD Implementation Approach and Challenges**

The SA team has implemented a simple workflow to illustrate the findings above. Such workflow consists of:

1.  Frontend repository is hosted on GitHub
    
2.  Two Github Actions have been developed.
    
3.  The development process in such a repo starts on the development branch, and for each new development iteration, a features/xxxx is created.
    
    1.  This provides an entry in Contentstack containing information about current developments.
        
    2.  This entry also has a workflow, which can be leveraged to synchronize global fields, content types, and content using an automation hub.
        
    
4.  At that point, both code and content changes can take place.
    
5.  Once the code changes are completed, The feature branch is merged back to develop.
    
6.  The Content Management Workflow for merging occurs in the CMS, combining workflow stages and AH Automation.
    

**The full Automation flow is as follows:**

  

![BranchesFoundations-L9-img-2.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/bltec19c524ad6f85ac/67dd8656db243fa79d12c3be/BranchesFoundations-L9-img-2.png)

**Gaps on AH**

*   Most of the required logic happens in code blocks, as the built-in actions don’t support certain functionality. Attempting to implement usable loops and conditional execution natively in AH would be cumbersome if possible.
    
*   Timeouts and API limits can occur, and since it’s all “Javascript Code Blocks,” the developer would need to deal with all this.
    
*   Developer experience on Code Blocks is very poor. Understandably, such blocks are not meant for full-blown development. For such reasons, most developers will resort to external services, rendering AH unnecessary beyond its usage as a webhook trigger. 
    

**Gaps in the API/CLI**

*   Create and Update works and can potentially be used for parts of the workflow above (content type and global fields merge). Content without asset/reference changes can also be merged.
    
    *   Implementing all the possible field updates (embedded items in JSON RTE, asset fields, reference fields, etc…) will require more logic to be developed.
        
    
*   Alternatively, we could use Merge & Compare for the above,  however, the fact that content can’t be merged poses a problem in these pipelines as most of the changes are potentially gonna be content. I.e., 2-5 content types/global field changes vs. dozens of content updates in that period.
    
*   Entry creation/update requires a lot of preprocessing when it comes to dealing with asset and reference fields besides the dependency hierarchy management for those fields can become tedious as well (i.e., first updated global fields, then content types, first assets, then referenced entries, then top-level entries)
    
*   When doing this at scale, API limits will pose a problem, too.
    

# **Streamlined CI/CD process for Contentstack Development Lifecycle (CDL) using Branch Merge Compare, Workflow, and Automation Hub**

## **Problem Statement** 

The Contentstack Branch Merge and Compare feature is an essential setup for the CI/CD process. We do have Merge and Compare via CLI, but there is a big gap to streamlining content type merge through UI with proper review process as this bring potentially big change to the production site.

*   Review Branch Comparison to choose the correct Merge strategy through UI
    
*   Merge branch Changes using the Workflow trigger feature with a proper review process and accessibility to specific roles 
    
*   Get details on merge failure reasons
    
*   Migrate bulk Entries from one branch to another based on new content type
    
*   Generate pull requests for GitHub code to move changes from the dev branch to the main branch
    
*   Smooth Rollback in case of breaking changes in an automated way to bring the Contentstack branch and GitHub branch to the previous state.
    

Drawbacks in Existing merge flow

Benefits of this new merge flow

The user should have a technical background due to CLI

No technical background is required after the setup

Time-consuming

Fast

There is no authorization flow during the merge

Proper authorization flow

No intimation after the merge operation about failure reasons

Notification System to send email with merge operation results

### **Use cases while working with Branches.**

1.  Streamlining Content and Code Development Life Cycle through automated CI/CD pipeline Mechanism
    
2.  Proper Authorisation Review workflow Process for major Content model changes for production using custom roles.
    
3.  Notification System in place for Review and merge operation using Automation hub.
    
4.  Quick and Easy way to back in case of breaking merge changes
    

## **Solution overview**

1.  Branch Merge Configuration using Merge Configuration Entry
    
2.  Workflow Stage to trigger branch merge
    
3.  Custom Role for Accessibility
    
4.  Automation Hub Actions
    
    1.  Merge Content type/Global field
        
    2.  Send Email Notification with merge summary and merge success and Failure details.
        
    3.  Migrate Entries to the target branch
        
    4.  GitHub Pull Request for Code Merge
        
    5.  Deploy UI Change using Launch/vertical/netlify
        
    

### **Flow Diagram**  

![BranchesFoundations-L9-img-3.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt6cd7aac9f5106525/67dd866fefd8a90c434c0188/BranchesFoundations-L9-img-3.png)

### **Streamlined UI Flow**

![BranchesFoundations-L9-img-4.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt84d66286aabbd951/67dd8687782bfb3b536f56bf/BranchesFoundations-L9-img-4.png)

![BranchesFoundations-L9-img-5.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt46251d40a3c8c5b6/67dd869ba6d88e2310053555/BranchesFoundations-L9-img-5.png)

![BranchesFoundations-L9-img-6.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt44a323f214288c3b/67dd86b10c6f55d8081fcf9c/BranchesFoundations-L9-img-6.png)

# **Branches Real-world Scenarios**

[Branches](https://www.contentstack.com/docs/developers/branches/about-branches) allow you to make changes and iterate your work without the risk of impacting the content deployed on production. Thus making it easier for developers to work on multiple releases simultaneously.

Let's examine the following use cases to learn how to work with Branches in Contentstack.

## **Example 1: Use branches for in-progress and production content**

Before branches, developers maintained different stacks, one for development and another for production content. These multiple cloned stacks in your organization made it difficult for developers to migrate their changes to production.

With branches, you can reduce the stacks in your organization by maintaining the development and production branches within one stack.

To achieve this, you must create a development branch within your production stack and select the production (main) branch as your source branch.

![BranchesFoundations-L9-img-7.png](https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt2cd3dab330db00c3/67dd86cba6d88e49ad053559/BranchesFoundations-L9-img-7.png)

The development branch will now have a copy of all the content from the main branch (production). With this development branch, the developers can modify the structure, add new changes, iterate, and publish in a testing environment to preview the recent changes.

**Additional Resource:** To create a new branch, read our doc on [creating a branch](https://www.contentstack.com/docs/developers/branches/create-a-branch).

You can compare the differences between the development and main branches in content types and global fields. Once satisfied with the changes, you can merge the development branch into the main one.

**Additional Resource:** Refer to our [Get Started with Comparing and Merging Branches](https://www.contentstack.com/docs/developers/branches/get-started-with-comparing-and-merging-branches) documentation to learn more about comparing and merging branches

When merging, a backup of the branch you are merging into (in this case, the main branch) is created by default before the merge action takes place. If you use aliases, you can easily point the alias to this backup branch to quickly switch back to how things were before the merge occurred.

**Additional Resource:** To learn how to assign a new alias or modify an alias, read our doc on how to [Assign an Alias](https://www.contentstack.com/docs/developers/branches/assign-an-alias-to-a-branch) or [Edit an Alias](https://www.contentstack.com/docs/developers/branches/edit-an-alias).

## **Example 2: Use branches to redesign your website**

Suppose you want to redesign the entire website. Traditionally you would clone the stack and make changes in the cloned model. However, with numerous content types and stacks, keeping track of the original content and the cloned one becomes difficult.

With the use of branches, you can redesign or restructure your website with great ease. You only need to create a branch named "redesign" and select the existing content (main) branch as your source branch.

![About\_Branches.png](https://images.contentstack.io/v3/assets/blt2d43f51baca745a8/blt4d0886f379752ad3/64802acdd242046f041ca2eb/About_Branches.png)

You can make structural changes to your content types and global fields in the redesigned branch. Once satisfied with your changes, you can compare the differences and merge the redesigned branch into the main branch using the overwrite with compare strategy to completely replace the main (base) branch with the newly redesigned changes from the redesign (compare) branch.

**Note:** The [Compare](https://www.contentstack.com/docs/developers/branches/comparing-branches) and [Merge](https://www.contentstack.com/docs/developers/branches/merging-branches) feature only compares and 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/#comparing-branches) and [CLI commands](https://www.contentstack.com/docs/developers/cli/compare-and-merge-branches-using-the-cli/).

## **Example 3: Use branches to prevent data loss**

Consider a developer who restructures the content model of an existing production website. Not aware of these recent changes, a content manager updates the content and publishes it to production.

Due to unintentional changes, the production website may break, resulting in content loss.

You can correct this minor error by restoring the previous version. However, if the developer had restructured many content types, this may be a tedious restoration activity.

With branches, one can avoid costly website errors and prevent data loss.

To do so, the developer can create a new branch named "test" and select the main or desired branch as the source branch.

![Branches\_Real-WorldScenarios\_Ex\_3.png](https://images.contentstack.io/v3/assets/blt2d43f51baca745a8/blt9dcb87cd13a3ad55/64802f3e352ac607a8da1952/Branches_Real-WorldScenarios_Ex_3.png)

The content of the source branch will now be available in the test branch. The developer can iterate the content model with great ease.

Then, when the content looks good, use an alias to reflect the new changes on the production website.

Once you are done and satisfied with your changes, you can compare and merge the two branches.

## **Example 4: Integrate branches and aliases with CI/CD for an instant release rollback capability**

Many development teams in the CI/CD pipeline use Git-based branching methods to maintain consistent code integration across the developer workflow. Once the integration is done, CD tools automate application code deployment to the desired environment (e.g., production).

With branches and aliases, developers can maintain production content across branches without affecting live website data. Content managers can publish content changes to a website without the assistance of a development team to pull content from Contentstack and display it on a presentation layer.

Aliases can always point back to the previously referenced content branch in case of unintentional content deployment. This flexibility allows developers to roll back changes instantly. Here, CI/CD can integrate with the CMS to automate rollback for such content changes.

**Additional Resource**: Refer to our [Use Branches and Aliases to Drive Continuous Integration and Deployment](https://www.contentstack.com/docs/developers/branches/use-branches-and-aliases-to-drive-continuous-integration-and-deployment) document to learn how branches and aliases help integrate Contentstack with standard CI/CD practices.

Let's consider a scenario where we need to change production data for a live website.

To integrate Contentstack with your CI/CD strategies to facilitate consistent, hassle-free content deployment to the live website, you can follow the below steps:

Create a copy of the **main** branch content in a separate branch to change your production data. The child branch you create inherits all of the content types, entries, assets, languages, extensions, releases, etc., that were part of the parent branch as it is.

![Branches\_Real-WorldScenarios\_Ex\_4.png](https://images.contentstack.io/v3/assets/blt2d43f51baca745a8/blt5dd3895967c419e4/64803004e73df5eeaea6e696/Branches_Real-WorldScenarios_Ex_4.png)

  

1.  Assign an alias to the "production" branch with the alias ID "deploy," for instance. This alias will help fetch and display data from the target branch on the live website.
    
2.  Specify an alias ID in the frontend code against the branch key to tell the application where it needs to fetch content. Whichever branch is associated with that alias ID becomes the production environment's main branch. For instance, we pass the "deploy" alias ID here to fetch data from the "production" branch.
    
3.  Change content types, entries, assets, etc., present on a branch (e.g., "development") without affecting your "production" branch data. You can test the changes until they are ready to deploy to production.
    
4.  Once the "development" branch changes are ready to go, you can use two different ways to apply the changes to production data:
    
    *   **For minor changes,** such as adding or removing a few fields, you can use the Contentstack CLI to apply these changes to the "production" branch.
        
    *   **For major changes** such as redesigning the marketing website, you can use an alias to point to the “development” branch to test your new changes. Once satisfied with your changes, you can merge the development (compare) branch into the production (base) branch.  
        
    
    ![Edit\_Alias.png](https://images.contentstack.io/v3/assets/blt2d43f51baca745a8/blt74fb9a049d62588d/64ab91a2873fa3a3b302f906/Edit_Alias.png)
    

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. With flexible release rollback capabilities, branches allow Contentstack to align with your CI/CD pipeline and strategies.

**Additional Resource:** To understand comparing and merging branches, please read our end-to-end guide on [Getting Started with Comparing and Merging Branches.](https://www.contentstack.com/docs/developers/branches/get-started-with-comparing-and-merging-branches/)

#### Key takeaways

- Connect **Case Studies With 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.

### Lesson 10 — Limitations of using Branches

<!-- ai_metadata: {"lesson_id":"10","type":"text","duration_minutes":1,"topics":["Limitations","using","Branches"]} -->

#### Lesson text

*   This feature will be plan-based.
    
*   The branch UID must be in lowercase, and only ‘\_’ can be used to separate two words.
    
*   The maximum number of branches allowed per stack will depend on the product tier.
    
*   Once you create a branch, you cannot edit its name or source branch.
    
*   The maximum character length for a branch ID is **15**
    
*   You cannot edit the name of the main branch.
    
*   You cannot delete a branch used as a source branch.
    
*   The Compare and Merge features are currently available only through CMA and CLI for the content type and global field modules only.
    

# **Limitations of Aliases**

*   This feature will be plan based.
    
*   The alias UID must be in lowercase and only ‘\_’ can be used to separate two words.
    
*   The alias UID and branch UID cannot be the same.
    
*   Once you create an alias, you cannot edit its name.
    
*   The maximum number of aliases allowed per stack will depend on the product tier.
    
*   The maximum character length for an alias name is **15**
    

# **FAQ**

Please take a moment to browse our Frequently Asked Questions (FAQ) for quick answers to common queries. Whether you're curious about branches, aliases, or services, our FAQ page provides comprehensive information to help address your concerns.

[Click here to explore our FAQ now](https://www.contentstack.com/docs/faqs#branches-faqs).

#### Key takeaways

- Connect **Limitations of using 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.

### Lesson 11 — Branches Foundations Quiz

<!-- ai_metadata: {"lesson_id":"11","type":"text","duration_minutes":1,"topics":["LMS","Knowledge check"]} -->

#### Lesson text

**This lesson is a knowledge check hosted in the Academy LMS.** This companion Markdown contains **no quiz questions, answers, scoring rules, or explanations**.

#### Key takeaways

- Connect **Branches Foundations Quiz** 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.

## Resources & references

| Page | Companion Markdown |
| --- | --- |
| /courses/branches-foundations/branches-in-contentstack | /academy/md/courses/branches-foundations/branches-in-contentstack.md |
| /courses/branches-foundations/creating-branches-overview | /academy/md/courses/branches-foundations/creating-branches-overview.md |
| /courses/branches-foundations/creating-branches | /academy/md/courses/branches-foundations/creating-branches.md |
| /courses/branches-foundations/working-with-branches-about-aliases | /academy/md/courses/branches-foundations/working-with-branches-about-aliases.md |
| /courses/branches-foundations/deleting-a-branch | /academy/md/courses/branches-foundations/deleting-a-branch.md |
| /courses/branches-foundations/comparing-branches | /academy/md/courses/branches-foundations/comparing-branches.md |
| /courses/branches-foundations/merging-branches | /academy/md/courses/branches-foundations/merging-branches.md |
| /courses/branches-foundations/environments-and-branches | /academy/md/courses/branches-foundations/environments-and-branches.md |
| /courses/branches-foundations/case-studies-with-branches | /academy/md/courses/branches-foundations/case-studies-with-branches.md |
| /courses/branches-foundations/limitations-of-using-branches | /academy/md/courses/branches-foundations/limitations-of-using-branches.md |
| /courses/branches-foundations/branches-foundations-quiz | /academy/md/courses/branches-foundations/branches-foundations-quiz.md |

## Supplement for indexing

### Content summary

Branches Foundations This course will outline the Contentstack features and techniques for using Branches with your Contentstack implementation. Completion of this course earns a 'badge' for this topic. Pre-requisites fo… Branches Foundations This course will outline the Contentstack features and techniques for using Branches with your Contentstack implementation. Completion of this course earns a 'badge' for this topic. Pre-requisites for this course 1. Account in Contentstack with access to a Stack as an Administrator or Developer. Create a training Stack here (https://www.contentstack.com/academy/). Training stacks are available for 90 days. Alternatively, you can bootstrap a Starter App via the CLI (https://www.contentstack.com/docs/developers/cli/bootstrap-starter-apps) or the Marketplace (https://app.cont

### Retrieval tags

- branches
- headless cms
- composable
- contentstack
- branches-foundations
- Creating
- Overview
- Working
- with
- About
- Aliases
- Deleting
- Branch
- Comparing

### Indexing notes

Chunk at each "### Lesson NN — Title" heading; copy lesson_id and topics from the preceding HTML comment into chunk metadata for RAG filters.
Course slug: branches-foundations. Union of lesson topic tokens: Branches, Contentstack, Creating, Overview, Working, with, About, Aliases, Deleting, Branch, Comparing, Merging, Environments, and, Case, Studies, With, Limitations, using, Foundations, Quiz.
Do not embed or retrieve LMS-only quiz items or mastery exam answer keys from this export.

### Asset references

| Label | URL |
| --- | --- |
| branches-token.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/bltb75e380c0f638072/664d4eaa78533908439e4fac/branches-token.png` |
| BranchesFoundations-L3-img-2.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt5ac58f90e15ecec3/67dc8839983a6519853b73d2/BranchesFoundations-L3-img-2.png` |
| BranchesFoundations-L3-img-3.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/bltff9181c58c6a9665/67dc886545b229efcb910ded/BranchesFoundations-L3-img-3.png` |
| BranchesFoundations-L3-img-4.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/bltc0d6b1880c4370b8/67dc888add73e3919fbf2be3/BranchesFoundations-L3-img-4.png` |
| BranchesFoundations-L3-img-5.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt31eb048058c803d3/67dc88a398672543b08881e6/BranchesFoundations-L3-img-5.png` |
| BranchesFoundations-L3-img-6.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/bltf5c89f40d9347533/67dc88beb1a1f3c27c3ef06b/BranchesFoundations-L3-img-6.png` |
| BranchesFoundations-L3-img-7.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt99acc19d22f87666/67dc88d545b229e98e910df3/BranchesFoundations-L3-img-7.png` |
| BranchesFoundations-L3-img-8.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt765540af59682c04/67dc88f4037e2ba01b22d1b3/BranchesFoundations-L3-img-8.png` |
| BranchesFoundations-L3-img-9.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blta7b764092858f5f6/67dc890df7eccc8c0490cfcd/BranchesFoundations-L3-img-9.png` |
| BranchesFoundations-L4-img-1.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/bltf3ae6fd09d0a4180/67dd7cef4a89c363a3a302d6/BranchesFoundations-L4-img-1.png` |
| BranchesFoundations-L4-img-2.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blteeed469e133f89c6/67dd7d09443bd66408f1cac0/BranchesFoundations-L4-img-2.png` |
| image.png | `https://images.contentstack.io/v3/assets/blt23180bf2502c7444/bltd4b6c9e986ebe3b3/615a8198db34085ff954a01a/image.png` |
| BranchesFoundations-L4-img-3.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/bltb0250e6a3d00cb61/67dd7d269867253c8c8889a4/BranchesFoundations-L4-img-3.png` |
| image.png | `https://images.contentstack.io/v3/assets/blt23180bf2502c7444/bltb2076ae6c5b6ab70/615a8202c22cd45706cf29d5/image.png` |
| Delete\_Branch.png | `https://images.contentstack.io/v3/assets/blt23180bf2502c7444/blt97e38c2305ea7e51/62192f310e638750b44cd638/Delete_Branch.png` |
| BranchesFoundations-L4-img-6.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt1505b71823069981/67dd7d579867252c408889b4/BranchesFoundations-L4-img-6.png` |
| BranchesFoundations-L4-img-7.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/bltac3fd31b34a7265e/67dd7d71c9b8d44ac6d141c1/BranchesFoundations-L4-img-7.png` |
| BranchesFoundations-L4-img-8.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt7765245e272b64d8/67dd7d8bc566eed34c5e0055/BranchesFoundations-L4-img-8.png` |
| BranchesFoundations-L4-img-9.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt62c1befbeedc4d9c/67dd7da23a0f38dd4a00eac8/BranchesFoundations-L4-img-9.png` |
| BranchesFoundations-L4-img-10.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt8b262655ba906d61/67dd7dbadd73e3fa86bf347b/BranchesFoundations-L4-img-10.png` |
| BranchesFoundations-L4-img-11.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/bltbcb81879dc42412b/67dd7dd35e486d801571b55c/BranchesFoundations-L4-img-11.png` |
| BranchesFoundations-L4-img-12.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt8b6ba3c18e1f4be7/67dd7ded37e25a6feb1e460d/BranchesFoundations-L4-img-12.png` |
| BranchesFoundations-L4-img-13.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt32c546a9f855b8d3/67dd7e0498672522078889c2/BranchesFoundations-L4-img-13.png` |
| BranchesFoundations-L5-img-1.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt78563255bd9268cc/67dd7e810c6f5553861fcef1/BranchesFoundations-L5-img-1.png` |
| BranchesFoundations-L5-img-2.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt667ca21ead42a562/67dd7ea2c5b83e650e924b8e/BranchesFoundations-L5-img-2.png` |
| BranchesFoundations-L5-img-3.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/bltc2f10243ea60bd3f/67dd7ebbc566ee10565e0075/BranchesFoundations-L5-img-3.png` |
| BranchesFoundations-L5-img-4.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt0c0aed4460902b62/67dd7ed3983a65c6393b7c44/BranchesFoundations-L5-img-4.png` |
| BranchesFoundations-L5-img-5.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/bltf713e8213a26cb19/67dd7ee9782bfb67eb6f5634/BranchesFoundations-L5-img-5.png` |
| BranchesFoundations-L5-img-6.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/bltdba319de396dc790/67dd7efe0c6f5566621fcf14/BranchesFoundations-L5-img-6.png` |
| BranchesFoundations-L5-img-7.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blte6fc933625df28b1/67dd7f134a89c3933aa3030b/BranchesFoundations-L5-img-7.png` |
| BranchesFoundations-L5-img-8.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt36345100a21a082c/67dd7f36782bfb67156f5641/BranchesFoundations-L5-img-8.png` |
| BranchesFoundations-L6-img-1.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/bltad81e23580acf738/67dd7f9bf7eccc607890d8af/BranchesFoundations-L6-img-1.png` |
| BranchesFoundations-L6-img-2.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt830e2f5390decd80/67dd7fc3339f292cd78b60dd/BranchesFoundations-L6-img-2.png` |
| BranchesFoundations-L6-img-3.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blte59d7f5914a6c4bd/67dd7fd9b1a1f361133ef8aa/BranchesFoundations-L6-img-3.png` |
| BranchesFoundations-L6-img-4.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt3da3b2c03699be5f/67dd7fed6f68581be5fda869/BranchesFoundations-L6-img-4.png` |
| BranchesFoundations-L6-img-5.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt3ec2aee61550fa99/67dd8005efd8a9099c4c00e5/BranchesFoundations-L6-img-5.png` |
| BranchesFoundations-L6-img-6.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/bltee56270033ba97d1/67dd801a17f7b4915d0d0173/BranchesFoundations-L6-img-6.png` |
| BranchesFoundations-L6-img-7.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blta26e739a070f547b/67dd80330c6f5559d01fcf28/BranchesFoundations-L6-img-7.png` |
| BranchesFoundations-L6-img-8.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blte1bde4be421df008/67dd80495e486d5c7371b5a5/BranchesFoundations-L6-img-8.png` |
| BranchesFoundations-L6-img-9.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/bltf5233f1e1a241292/67dd80686f68581895fda877/BranchesFoundations-L6-img-9.png` |
| BranchesFoundations-L6-img-10.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt870a0938f973914f/67dd80830c6f555c231fcf32/BranchesFoundations-L6-img-10.png` |
| BranchesFoundations-L6-img-11.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt4363c1710c1de892/67dd809c6f685822d2fda882/BranchesFoundations-L6-img-11.png` |
| BranchesFoundations-L6-img-12.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt0f4254e5752bbc4d/67dd80bb20a3dcd689f8285e/BranchesFoundations-L6-img-12.png` |
| BranchesFoundations-L6-img-13.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt6724b3e928297c65/67dd80d9460eb4086594780c/BranchesFoundations-L6-img-13.png` |
| 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` |
| BranchesFoundations-L9-img-1.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt80669c6c79b6ff1f/67dd863ac5b83eaf0b924c25/BranchesFoundations-L9-img-1.png` |
| BranchesFoundations-L9-img-2.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/bltec19c524ad6f85ac/67dd8656db243fa79d12c3be/BranchesFoundations-L9-img-2.png` |
| BranchesFoundations-L9-img-3.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt6cd7aac9f5106525/67dd866fefd8a90c434c0188/BranchesFoundations-L9-img-3.png` |
| BranchesFoundations-L9-img-4.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt84d66286aabbd951/67dd8687782bfb3b536f56bf/BranchesFoundations-L9-img-4.png` |
| BranchesFoundations-L9-img-5.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt46251d40a3c8c5b6/67dd869ba6d88e2310053555/BranchesFoundations-L9-img-5.png` |
| BranchesFoundations-L9-img-6.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt44a323f214288c3b/67dd86b10c6f55d8081fcf9c/BranchesFoundations-L9-img-6.png` |
| BranchesFoundations-L9-img-7.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt2cd3dab330db00c3/67dd86cba6d88e49ad053559/BranchesFoundations-L9-img-7.png` |
| About\_Branches.png | `https://images.contentstack.io/v3/assets/blt2d43f51baca745a8/blt4d0886f379752ad3/64802acdd242046f041ca2eb/About_Branches.png` |
| Branches\_Real-WorldScenarios\_Ex\_3.png | `https://images.contentstack.io/v3/assets/blt2d43f51baca745a8/blt9dcb87cd13a3ad55/64802f3e352ac607a8da1952/Branches_Real-WorldScenarios_Ex_3.png` |
| Branches\_Real-WorldScenarios\_Ex\_4.png | `https://images.contentstack.io/v3/assets/blt2d43f51baca745a8/blt5dd3895967c419e4/64803004e73df5eeaea6e696/Branches_Real-WorldScenarios_Ex_4.png` |
| Edit\_Alias.png | `https://images.contentstack.io/v3/assets/blt2d43f51baca745a8/blt74fb9a049d62588d/64ab91a2873fa3a3b302f906/Edit_Alias.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/` |
| Starter App via the CLI | `https://www.contentstack.com/docs/developers/cli/bootstrap-starter-apps` |
| Marketplace | `https://app.contentstack.com/#!/marketplace/starters` |
| authtoken | `https://www.contentstack.com/docs/developers/create-tokens/types-of-tokens#authentication-tokens-authtokens` |
| branches-token.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/bltb75e380c0f638072/664d4eaa78533908439e4fac/branches-token.png` |
| https://www.contentstack.com/docs/developers/cli/install-the-cli | `https://www.contentstack.com/docs/developers/cli/install-the-cli` |
| BranchesFoundations-L3-img-2.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt5ac58f90e15ecec3/67dc8839983a6519853b73d2/BranchesFoundations-L3-img-2.png` |
| BranchesFoundations-L3-img-3.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/bltff9181c58c6a9665/67dc886545b229efcb910ded/BranchesFoundations-L3-img-3.png` |
| BranchesFoundations-L3-img-4.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/bltc0d6b1880c4370b8/67dc888add73e3919fbf2be3/BranchesFoundations-L3-img-4.png` |
| BranchesFoundations-L3-img-5.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt31eb048058c803d3/67dc88a398672543b08881e6/BranchesFoundations-L3-img-5.png` |
| BranchesFoundations-L3-img-6.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/bltf5c89f40d9347533/67dc88beb1a1f3c27c3ef06b/BranchesFoundations-L3-img-6.png` |
| BranchesFoundations-L3-img-7.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt99acc19d22f87666/67dc88d545b229e98e910df3/BranchesFoundations-L3-img-7.png` |
| BranchesFoundations-L3-img-8.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blt765540af59682c04/67dc88f4037e2ba01b22d1b3/BranchesFoundations-L3-img-8.png` |
| BranchesFoundations-L3-img-9.png | `https://images.contentstack.io/v3/assets/bltebc53cfaf0dd6403/blta7b764092858f5f6/67dc890df7eccc8c0490cfcd/BranchesFoundations-L3-img-9.png` |
| Creating a branch using API | `https://www.contentstack.com/docs/developers/apis/content-management-api#create-a-branch` |
| Creating a branch using CLI | `https://www.contentstack.com/docs/developers/cli/compare-and-merge-branches-using-the-cli#create-a-branch` |
| Listing Branches using CLI | `https://www.contentstack.com/docs/developers/cli/compare-and-merge-branches-using-the-cli#list-branches` |
| Creating a Branch using UI | `https://www.contentstack.com/docs/developers/branches/create-a-branch` |
| Alias | `https://www.contentstack.com/docs/developers/branches/about-aliases` |
| branch | `https://www.contentstack.com/docs/developers/branches/about-branches` |
| Contentstack account | `https://www.contentstack.com/login/` |
| stack | `https://www.contentstack.com/docs/developers/set-up-stack/about-stack` |
