Search code examples
gitlab

Change Default branch in gitlab


I accidentally pushed my local master to a branch called origin on gitlab and now it is the default. Is there a way to rename this branch or set a new master branch to master?


Solution

  • Updated:

    Prerequisites:

    • You have the Owner or Maintainer role in the project.

    To update the default branch for an individual project:

    1. On the left sidebar, select Search or go to find your project.
    2. Select Settings > Repository.
    3. Expand Branch defaults. For Default branch, select a new default branch.
    4. Optional. Select the Auto-close referenced issues on default branch checkbox to close issues when a merge request uses a closing pattern.
    5. Select Save changes.

    enter image description here

    To change a default branch name for an instance or group:

    1. On the left sidebar, at the bottom, select Admin Area.
    2. Select Settings > Repository.
    3. Expand Default branch.
    4. For Initial default branch name, select a new default branch.
    5. Select Save changes.

    change group