删除所有本地的Git分支 [英] Delete all local git branches

查看:1222
本文介绍了删除所有本地的Git分支的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遵循一个发展的过程,我创建的每个新功能或故事卡一个新的本地分支。当我完成合并支进主,然后按。

I follow a development process where I create a new local branch for every new feature or story card. When finished I merge the branch into master and then push.

发生随着时间的推移趋于什么因懒惰或健忘的组合,是我结束了与当地分支机构的大名单。

What tends to happen over time due to a combination of laziness or forgetfulness, is that I end up with a large list of local branches.

我知道如何列出我所有地方分公司,我知道如何删除单个分支,但我不知道是否有一个Git命令,让我删除我所有的地方分支机构?

I know how to list all my local branches and I know how to remove a single branch but I was wondering if there was a git command that allows me to delete all my local branches?

下面是的Git分支的输出--merged 命令。

user@machine:~/projects/application[master]$ git branch --merged
  STORY-123-Short-Description
  STORY-456-Another-Description
  STORY-789-Blah-Blah
* master

所有尝试删除与的grep -v上市分行\\ * (按照下面的答案),导致错误:

All attempts to delete branches listed with grep -v \* (as per the answers below) result in errors:

error: branch 'STORY-123-Short-Description' not found.
error: branch 'STORY-456-Another-Description' not found.
error: branch 'STORY-789-Blah-Blah' not found.

我使用的是:结果
Git的1.7.4.1结果
Ubuntu的10.04结果
GNU的bash,版本4.1.5(1)-release结果
GNU的grep 2.5.4

I'm using:
git 1.7.4.1
ubuntu 10.04
GNU bash, version 4.1.5(1)-release
GNU grep 2.5.4

推荐答案

刚一说明,我会升级到1.7.10的git。你可能会得到答案在这里,不会对你的版本。我的猜测是,你将不得不preFIX分支名裁判/头/

Just a note, I would upgrade to git 1.7.10. You may be getting answers here that won't work on your version. My guess is that you would have to prefix the branch name with refs/heads/.

注意,着手只有当你做你的工作文件夹和.git目录的副本以下。

我有时只是继续前进,从的.git /裁判/头删除我不想直的树枝。所有这些分支是是包含40个字符的SHA-1的提交它们指向文本文件。你会在你的的.git /配置无关的信息,如果你有具体的跟踪设置为任何人。您可以删除这些条目以及手动。

I sometimes just go ahead and delete the branches I don't want straight from .git/refs/heads. All these branches are are text files that contain the 40 character sha-1 of the commit they point to. You will have extraneous information in your .git/config if you had specific tracking set up for any of them. You can delete those entries manually as well.

这篇关于删除所有本地的Git分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆