在 git flow 中重命名一个分支

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29760651/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 10:55:35  来源:igfitidea点击:

Rename a branch in git flow

gitbranchgit-flow

提问by Andrew Grimm

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

是否可以使用 git-flow 重命名功能分支?

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

我尝试查找git flow helpgit flow feature help,以及git-flow 备忘单,但什么也找不到。

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

或者,仅使用安全git branch -m feature/new_name吗?

回答by CodeWizard

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.

您可以这样做,但是如果您推送了您的分支并且有人正在使用它,您将需要更新他们的更改。

gitflowbranches are no different then any other branch.

gitflow分支与任何其他分支没有什么不同。

Rename local branch

Rename local branch

Git beginner(Normal way)

Git初学者(正常方式)

#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 short git branch move (–move flag)
git branch --move <old_name> <new_name>


Advanced: Manually rename branch

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 :-)

回答by Giovanni

Yes, but if you use gitflow you also need to manually modify (I don't know if there is an automatic way to do that) the file .git/config, and rename the git-flow feature name for the feature you want to rename

是的,但是如果您使用 gitflow,您还需要手动修改(我不知道是否有自动方法)文件 .git/config,并为您想要的功能重命名 git-flow 功能名称改名

回答by Michael Sasser

You can use git-flow feature rename NewFeatureNameto rename a feature.

您可以使用git-flow feature rename NewFeatureName重命名功能。

This seems to be not very well documented. You can find the reference here

这似乎没有很好的记录。你可以在这里找到参考