Now Up To  80% OFF  GitKraken Pro
Upgrade to Save
Search
Close this search box.

How do you rename a Git branch?

Rename Git Branch

When working with your Git repositories, there will likely come a time when you wish to rename a Git branch that you’re working with. First, we’ll cover renaming a local Git branch and then renaming a remote Git branch; we will review the process using the cross-platform GitKraken Git GUI and the CLI.

In just 2 clicks, GitKraken lets you quickly rename local and remote branches. ⬇️

How do you rename a branch with GitKraken?

Let’s go over how to quickly do rename a Git branch using the GitKraken Git GUI for Windows, Mac, and Linux.

How do you rename a branch locally in GitKraken?

To rename a local branch using GitKraken, simply right-click on the branch and choose the Rename option from the context menu.

Next, type in your desired new branch name and hit Enter. The local branch will be renamed.

How do you rename a remote branch in GitKraken?

To update a remote Git branch in GitKraken, you will have to change the upstream by right-clicking the branch and selecting Set Upstream from the context menu.

Next, enter the new branch name and click Submit. You can then push the new Git branch up to the remote using the Push toolbar button, or from the context menu.

Lastly, you’ll have to delete the old remote branch by right-clicking it and selecting Delete origin/branch-name from the context menu.

Seemingly easy tasks in Git, like renaming a branch, are less intuitive and take more time without the power offered by GitKraken.

Learn More about Easy Git Features

How do you rename a Git branch locally in the command line?

When you want to rename a Git branch locally, you can do so using the git branch command with the -m option.

If you want to rename the current branch you have checked out, you can simply pass in your desired new name:

git branch -m <new-branch-name>

GitTip: Learn more about how to checkout a local Git branch.

Can you rename a local Git branch if you don’t have the branch checked out?

If you want to rename a different branch than the current branch you have checked out, you can use the same command, but pass in the current name of the branch followed by the new branch name:

git branch -m <branch-name><new-branch-name>

How do you rename a remote Git branch?

If the branch you are renaming has already been pushed to a remote, the upstream branch won’t change just because you renamed your local branch.

You can push the new branch to the remote and update the upstream using the git push command with the -u (or --set-upstream) option:

git push origin -u <new-branch-name>

GitTip: Learn more about how to set upstream of a branch in Git.

Now, you will just have to delete the old branch from the remote using the git push command with the -d (or --delete) option:

git push origin -d <branch-name>

GitTip: Learn more about how to delete a remote branch in Git.

The process to rename a Git branch is much faster and more intuitive using the GitKraken Git GUI, and you can avoid making changes to the wrong data by mistake.

Additional Resources

Table of Contents

Make Git Easier, Safer &
More Powerful

with GitKraken

Visual Studio Code is required to install GitLens.

Don’t have Visual Studio Code? Get it now.

Team Collaboration Services

Secure cloud-backed services that span across all products in the DevEx platform to keep your workflows connected across projects, repos, and team members
Launchpad – All your PRs, issues, & tasks in one spot to kick off a focused, unblocked day. Code Suggest – Real code suggestions anywhere in your project, as simple as in Google Docs. Cloud Patches – Speed up PR reviews by enabling early collaboration on work-in-progress. Workspaces – Group & sync repos to simplify multi-repo actions, & get new devs coding faster. DORA Insights – Data-driven code insights to track & improve development velocity. Security & Admin – Easily set up SSO, manage access, & streamline IdP integrations.
winget install gitkraken.cli