你能用Git在一个命令中删除多个分支吗? [英] Can you delete multiple branches in one command with Git?

查看:143
本文介绍了你能用Git在一个命令中删除多个分支吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想清理我的本地仓库,它有很多旧的分支:例如 3.2 3.2.1 3.2.2 等。



我希望有一种偷偷摸摸的方式来删除很多人一次。由于他们大多遵循点发布惯例,所以我想也许有一条捷径可以说:

  git branch -D 3.2。* 

并杀死所有3.2.x分支。



我试过这个命令,当然,它没有工作。 解决方案

但你可以这样做:

  git branch -D 3.2 3.2.1 3.2.2 

基本上,git分支会使用单个调用为您删除多个分支。不幸的是,它不会完成分支名称。虽然在bash中,你可以这样做:

  git branch -D`git branch | grep -E'^ 3 \.2\ .. *'`


I'd like to clean up my local repository, which has a ton of old branches: for example 3.2, 3.2.1, 3.2.2, etc.

I was hoping for a sneaky way to remove a lot of them at once. Since they mostly follow a dot release convention, I thought maybe there was a shortcut to say:

git branch -D 3.2.*

and kill all 3.2.x branches.

I tried that command and it, of course, didn't work.

解决方案

Not with that syntax. But you can do it like this:

git branch -D 3.2 3.2.1 3.2.2

Basically, git branch will delete multiple branch for you with a single invocation. Unfortunately it doesn't do branch name completion. Although, in bash, you can do:

git branch -D `git branch | grep -E '^3\.2\..*'`

这篇关于你能用Git在一个命令中删除多个分支吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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