> For the complete documentation index, see [llms.txt](https://www.pranaypourkar.co.in/the-programmers-guide/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.pranaypourkar.co.in/the-programmers-guide/git/platforms/gitlab/freeze-a-branch.md).

# Freeze a branch

## About

Freezing a branch in GitLab isn't a built-in GitLab feature per se, but we can **prevent changes** to a branch by using a combination of GitLab settings and permissions. This is commonly done when we want to **lock** or **freeze** a release or production branch.

Here are common methods to "freeze" a branch in GitLab:

## Option 1: **Protect the Branch (Recommended for Freezing)**

This will prevent anyone (or certain roles) from pushing or force-pushing to the branch.

**Steps:**

1. Go to your GitLab project.
2. Navigate to: `Settings` → `Repository`.
3. Scroll to **Protected Branches**.
4. In the **"Protect a branch"** section:
   * Choose the branch you want to freeze (e.g., `release`, `main`).
   * Set:
     * **Allowed to push:** `No one`
     * **Allowed to merge:** `No one` *(or keep Maintainers if needed for hotfixes)*
   * Click **Protect**.

> This effectively freezes the branch: no one can push, force push, or merge into it unless you modify these settings.

<figure><img src="https://3632859567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPd6ktrA5pPLsZJktj2fm%2Fuploads%2Fr7hr63RZp9hpGgkCjAGE%2Ffreeze-branch-gitlab.png?alt=media&amp;token=c7a2b35f-e3ae-46a6-b8c9-1aa7c6d1c45f" alt=""><figcaption></figcaption></figure>

### Option 2: **Tag the Branch Instead of Freezing**

If the goal is to preserve the current state for a release, you can create a **Git tag** (e.g., `v1.0.0`) and treat that as frozen.

```bash
git checkout release
git tag -a v1.0.0 -m "Release version 1.0.0"
git push origin v1.0.0
```

Tags are immutable by default in GitLab (unless explicitly allowed to be moved), so this provides a "freeze snapshot" without freezing the actual branch.

### Option 3: **Use Code Owners + Merge Request Rules (Premium+)**

If you have GitLab Premium or higher, you can:

* Define `CODEOWNERS` file for the branch.
* Require approval from code owners before merging.
* Combine this with protected branches.

This doesn’t freeze the branch but **controls who can change it**, useful for controlled release branches.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://www.pranaypourkar.co.in/the-programmers-guide/git/platforms/gitlab/freeze-a-branch.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
