How can I rename my branch from TortoiseGit?
Asked Answered
M

3

51

I know the way to rename branch from command line, but - since I'm using TortoiseGit - I'm curious if there are any options to do such thing.

Thanks for the answers :)

Managua answered 21/3, 2016 at 14:9 Comment(0)
P
59

In a File Manager, Open your Project root directory (where your .git folder is found).

Right click and go to:

TortoiseGit > Switch/Checkout

Ensure the Switch To Option to Branch. Then click the little button to the side of the drop down menu that is denoted by ...

A window will pop up showing the list of branches for you to choose.
Click on the one you want to rename.

Hit F2.

Rename your branch. Hit Enter. Click OK.

Now in the drop down menu, you'll find that the branch-name has been updated.

Piggyback answered 21/3, 2016 at 14:47 Comment(2)
You don't need to use the detour using the switch dialog, you can directly open the browse references dialog, see https://mcmap.net/q/346083/-how-can-i-rename-my-branch-from-tortoisegitLangsdon
This does not update remote tracking branches.Langsdon
L
22

If you want to rename a branch which is not the current branch, open the Reference Browser using the context menu of a versioned folder (you might need to hold the Shift key when opening it).

enter image description here

select the branch you want to rename and then press F2 (or select rename in the context menu).

enter image description here

See https://tortoisegit.org/docs/tortoisegit/tgit-dug-browse-ref.html

Langsdon answered 21/3, 2016 at 15:17 Comment(3)
I think this is much more intuitive and works just fine for current branch too.Piacular
This works great but remember that it doesn't rename your remote branch. Easy way is to just delete the original remote and then push your renamed one. Here's how to delete a remote: #9706034Mai
@rusty, no need to delete the branch. Do this instead. -> Switch to renamed branch. -> Right click the repository -> Git commit <renamed branch> -> Git commit window will open. Write a commit message in the message window, for example: "renaming a branch..." -> In the bottom left corner, tick the checkbox "Message Only" -> Commit & PushAdaline
A
1

If you want to rename just the local branch, you can refer to other answers. Please follow these steps to rename local and remote branch.

  1. Right click the repository -> TortoiseGit -> Browse References.

enter image description here

  1. Select the branch you want to rename and hit F2 button and type a new name. The branch is now been renamed locally.

enter image description here

  1. Right click the renamed branch and select "switch/checkout to this.."

enter image description here

  1. Now right click the repository and select "Git Commit -> "renamed branch"

enter image description here

  1. Git commit window will open. Type a commit message and tick the checkbox "Message Only" in the bottom left corner, and then click "Commit & Push"

enter image description here

Press the upvote button if this answer has helped you.

Adaline answered 6/12, 2019 at 8:3 Comment(4)
I tried this twice. All it does on the remote side is put a commit with a message, no other changes. Remote Branch name stays the same.Fagan
Don't you see a branch with new name on remote side?Adaline
Nope... old branch name has new message only commit. No new branch name is found. I ended up having to do this instead.Fagan
The following steps work for me: 1. Open 'Browse references.' 2. Delete the remote branch. 3. Rename the local branch. 4. Right-click on the local branch and select "Unset tracked branch." 5. Now, you can publish again.Damico

© 2022 - 2024 — McMap. All rights reserved.