Yes.
First, to clarify your question.
In GitLab, the first branch (not necessarily named master
) pushed to the repository becomes the default branch which has special meaning. It is the default branch checked out by clients on a clone, and it is the default merge request target. Also, it is usually protected.
When you say "rename master", I assume you mean rename the branch, and change the default branch in GitLab.
First rename the branch locally.
git checkout master
git branch -m newname
Then push it to the server
git push -u origin newname
Now go to the GitLab web UI. Under Settings > Repository, change the "default branch" to newname
.
You'll also want to make sure that newname
is marked protected to prevent accidental loss by a force-push.
Then delete master
on GitLab from the branches page.
With that said, please don't do this. master
is an extremely well-known convention and this change will be surprising to other contributors.