Skip to content

Creating and Protecting Branches in GitLab

Creating branches allows you to isolate work, while protecting them prevents unwanted changes. This guide covers branch creation and how to protect branches by name or pattern. For overall management strategies, see Managing Protected Branches.

  1. From the UI:
    • Navigate to your project in GitLab.
    • Go to Repository > Branches.
    • Click New branch, provide a name, and choose a base branch.
    • Click Create branch.
  2. From the command line:
    Terminal window
    git checkout -b feature/new-feature origin/main
    git push -u origin feature/new-feature
  1. Go to Settings > Repository.
  2. Expand Protected Branches.
  3. In Branch name, either:
    • Enter the exact branch name (feature/new-feature), or
    • Use a wildcard like release/* to protect multiple branches.
  4. Set allowed roles for merge and push.
  5. Click Protect.