git 使用 gitflow 删除“功能”分支而不合并到主分支
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22137434/
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
delete a 'feature' branch using gitflow without merging into master branch
提问by johowie
I am using the Git GUI called 'Souretree' by Atlassian and in particular the 'Gitflow' module to manage various branches.
我正在使用 Atlassian 称为“Souretree”的 Git GUI,特别是“Gitflow”模块来管理各种分支。
I just created a 'release' branch that I don't want to merge back into either the master or develop branches. How do I get rid of it ? Can I just delete it ? My concern is that I mess up the gitflow config.
我刚刚创建了一个“发布”分支,我不想将其合并回 master 或 develop 分支。我该如何摆脱它?我可以删除它吗?我担心的是我弄乱了 gitflow 配置。
I have only made one commit to this branch which i don't care about.
我只对这个分支做了一个我不关心的提交。
回答by johowie
It seems that I can just delete the branch according to the following sources: Evan Hahndominiksymonowicz
看来我可以根据以下来源删除分支: Evan Hahn dominiksymonowicz
To quote Evan:
引用埃文的话:
To trash a branch using git-flow , simply delete it like you'd normally delete a Git branch:
git branch -D whatever/branch/you/wanna/delete
Note that this does a forced delete, so anything you did on that branch will be lost. You can be safer with the lowercase -d flag instead.
要使用 git-flow 删除分支,只需像通常删除 Git 分支一样删除它:
git branch -D whatever/branch/you/wanna/delete
请注意,这会强制删除,因此您在该分支上所做的任何事情都将丢失。使用小写 -d 标志可以更安全。
So using the sourcetree GUI interface i first changed to another branch ( in my case develop) and then simply right clicked on the release branch name in the list of branches in the left hand panel and selected Delete release/releaseName
. This gave me the option to do so with as a Force Delete, which in my case was necessary as I wanted to delete the unmerged commits as well.
因此,使用 sourcetree GUI 界面,我首先更改为另一个分支(在我的情况下为开发),然后只需右键单击左侧面板中分支列表中的发布分支名称并选择Delete release/releaseName
. 这让我可以选择强制删除,这在我的情况下是必要的,因为我也想删除未合并的提交。
回答by John
I actually wrote the below in a how to article for a development team last week, so I can share it here:
实际上,我上周在一篇为开发团队撰写的文章中写了以下内容,因此我可以在这里分享:
Delete a local branch
删除本地分支
git branch -d branch_name
Delete a remote branch
删除远程分支
git push origin --delete branch_name
If you don't delete the remote branch then you'll either have a problem when attempting to create a branch with the same name, or you'll leave a branch that needs to be pruned in the future.
如果您不删除远程分支,那么您在尝试创建同名分支时会遇到问题,或者您将留下一个需要在将来修剪的分支。
Also is it assumed that your remote is called origin, but if different then you'll need to change that above.
还假设您的遥控器被称为原点,但如果不同,那么您需要在上面进行更改。