SaltfishTry for free

How to Rename a Branch in Gitlab

·2 min read
In this article

Renaming branches in GitLab is a common task when you need to update branch names to better reflect their purpose or follow naming conventions. This process involves using Git commands through the command line interface to change both local and remote branch references.

This tutorial will walk you through the complete process of renaming a Git branch in your GitLab repository, from executing the rename command to verifying the changes have taken effect properly.

Here's how to rename a branch in Gitlab

  1. Open your terminal or command line interface and navigate to your GitLab repository directory.
  2. Execute the git branch -m command followed by the current branch name and the desired new branch name (for example: git branch -m bug-A bug-B).
  3. Press Enter to execute the branch rename command.
  4. Type git branch command to display all available branches in your repository.
  5. Verify that your branch has been successfully renamed by checking the branch list output.

Your turn to show how it works.

Build a walkthrough of your product with Saltfish, then share it with your customers.

Create a guide with Saltfish

Frequently Asked Questions

Yes, you can rename the branch you're currently on by using the git branch -m command with just the new name. Git will automatically rename the current branch without needing to specify the old name.