How to Change Default Branch in Gitlab
This tutorial will teach us how to change the default branch in Gitlab.
Gitlab is a web-based Git repository. It provides remote access to the Git repositories hosted on it.
We can push our local repository changes to the remote repository hosted on Gitlab. We can change the default branch of a project on Gitlab.
We will now illustrate this with an example.
Change Default Branch in Gitlab
Gitlab is also a complete DevOps platform that we can use to perform all kinds of tasks like planning, code management, monitoring, and security in a project. It has additional features designed to help manage the software development lifecycle.
In Gitlab, we create projects to host our codebases. When we create a new project on Gitlab, a default branch is made in the project’s repository.
Suppose we have a branch named master
on Gitlab that is the default branch. We may now wish to change the default branch name to main
on Gitlab.
We need to do the following steps to change the default branch name for a project in Gitlab.
-
Log in to Gitlab with a minimum Maintainer role.
-
In the Navigation menu, go to
Settings
>Repository
. -
Expand the
Default branch
section and then select a new default branch, viz.main
. -
Finally, select
Save changes
to change the default branch for the project.
Thus, we have learned how to change the default branch in Gitlab.
For more information, please visit: