Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to rename a local Git branch from inside IntelliJ IDEA?

There are plenty of things you can do with Git plugin for IntelliJ IDEA, but I haven't found a way to rename a branch. Is there one?

I know I can always bring up a terminal and do git branch -m source target, but I expected to find a GUI solution as well.

like image 779
gvlasov Avatar asked Aug 09 '15 06:08

gvlasov


People also ask

How do I rename a local Git branch?

The steps to change a git branch name are: Rename the Git branch locally with the git branch -m new-branch-name command. Push the new branch to your GitHub or GitLab repo. Delete the branch with the old name from your remote repo.

Can we rename the branch name in Git?

No, in order to rename a remote Git branch you need to delete the old branch name, and then push the correctly named branch to the remote repository.

How do you rename a branch?

To do this, use the following steps: Switch to the master via the command “git checkout master”. Now enter the following command if you want to rename a Git branch: “git branch -m old-name new-name”. To ensure that the rename was successful, retrieve the current status of the branch using the “git branch -a” command.


1 Answers

There are a couple of pending issues with this feature:

  • IDEA-89927: Renaming branches is not captured by IDEA
  • IDEA-131021: Add "Rename branch" action

The latter is not yet implemented.
The former does show the only way (mentioned by the OP) currently available:

Go to the command line and execute git branch -m <old_name> <new_name>

But even that has refresh issue on IDEA.


Update January 2017: IDEA-131021 might have been implemented, as illustrated by Pavlo Zvarych's answer. It is consistent with the proposal:

introduce menu item in Git | Branches popup for current branch and place the actions related to the current branch in its second-level submenu.

https://youtrack.jetbrains.com/_persistent/image.png?file=74-343247&c=true&rw=526&rh=121&u=1473876457355

like image 107
VonC Avatar answered Sep 24 '22 06:09

VonC