Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rename a branch in git flow

Tags:

Is it possible to rename a feature branch using git-flow?

I tried looking up git flow help and git flow feature help, and also the git-flow cheatsheet, but couldn't anything.

Alternatively, is it safe to just use git branch -m feature/new_name?

like image 885
Andrew Grimm Avatar asked Apr 21 '15 00:04

Andrew Grimm


1 Answers

Yep.

You can do it but if you pushed your branch and someone is using it you will need to update them about the change.

gitflow branches are no different then any other branch.

Rename local branch

Git beginner (Normal way)

#Checkout new branch and delete the old one git checkout -b <new_name> git branch -D <old_name>  #Use the short git branch move (-m flag) git branch -m <old_name> <new_name>  #Use the long git branch move (–move flag) git branch --move <old_name> <new_name> 

Advanced: Manually rename branch

(Not recommended- aka Don't try it at home !!!)

Rename the old branch under .git/refs/heads to the new name Rename the old branch under .git/logs/refs/heads to the new name Update the .git/HEAD to point to your new branch name.  Sit back and Enjoy GIT :-) 
like image 79
CodeWizard Avatar answered Sep 26 '22 03:09

CodeWizard