使用git批量删除分支
要删除本地,首先要考虑以下三点
- 列出所有本地分支
- 搜索目标分支如:所有含有‘dev’的分支
- 将搜索出的结果传给删除函数
所以我们可以得到:
git br |grep 'dev' |xargs git br -d
本地新建了很多分支,比如
$ git branch
brabch
branch2
branch3
branch4
chucklu_zhCN
* master
其中以bra开头的分支都是临时性的分支,用完之后需要删除,使用命令逐个删除就太麻烦了
$ git branch |grep 'bran'
branch2
branch3
branch4
$ git branch |grep 'bran'|xargs git branch -d
Deleted branch branch2 (was a84d992).
Deleted branch branch3 (was 95a769c).
Deleted branch branch4 (was 9e7aecb).
$ git branch |grep 'bra'|xargs git branch -d
Deleted branch brabch (was e71cd6d).
参考资料:
Linux中的管道命令操作符 | http://www.cnblogs.com/chengmo/archive/2010/10/21/1856577.html
grep命令 http://www.cnblogs.com/peida/archive/2012/12/17/2821195.html
批量删除分支(包括本地和远端的)http://scriptogr.am/pison/post/git
Delete git branches whose name matches a certain pattern
Update: The -r option to xargs is a GNU addon. Unless you use xargs from GNU findutils it might not work. You can omit it but that leads to an error if the input piped to xargs is empty.
You can use git branch --list <pattern> and pipe it's output to xargs git branch -d:
git branch --list 'o*' | xargs -r git branch -d
Btw, there is a minor issue with the code above. If you've currently checked out one of the branches that begins with o the output of git branch --list 'o*' would look like this:
* origin_master
origin_test
o_what_a_branch
Note the asterisk * in front of the current branch name.
While you cannot delete the current branch anyway, it leads to the fact that xargs also passes * to git branch delete.
As I say it is just a cosmetic error, but if you want to avoid it use:
git branch --list 'o*' | sed 's/^* //' | xargs -r git branch -d
使用git批量删除分支的更多相关文章
- git批量删除分支
要删除本地,首先要考虑以下三点 列出所有本地分支 搜索目标分支如:所有含有'dev'的分支 将搜索出的结果传给删除函数 所以我们可以得到: git br |grep 'dev' |xargs git ...
- Git批量删除
Git批量删除 git的改动都需要stage过程后才能commit.当git中有大量改动时就需要能够批量操作在方便.改动分三种: modify: 有文件修改 add: 有文件增加 rm: 有文件删除 ...
- git远程删除分支但本地git branch -a仍能看到解决
git远程删除分支但本地git branch -a仍能看到解决 在gitlab页面删除分支 但是本地能可以看到 $ git branch -a br_dev br_to_delete * master ...
- git 批量删除文件夹和文件
git 批量删除文件夹和文件 硬盘删除文件后,执行$ git status 会提示你仍然需要$ git rm <文件> 此时如果是要删除大批量文件,这么一个一个命令下去不得累死人啊 ...
- git批量删除本地分支及远程分支
1.批量删除本地分支 git branch |grep 'branchName' |xargs git branch -D git branch 查看本地分支 | grep 'branchName ...
- git 创建删除分支
进入仓库目录 -- 查看本地分支 git branch -- 查看远程分支 git branch -r -- 查看远程和本地的分支 git branch -a -- 下载远程分支代码,并切换到分支 进 ...
- git批量删除文件和批量提交
1. 单个删除文件: ① 通常直接在文件管理器中把没用的文件删了,或者用rm命令删了:(可选操作,可直接执行②删除) $ rm test.txt ② 确实要从版本库中删除该文件,那就用命令git rm ...
- git 批量删除本地分支
git branch | grep 'bug' |xargs git branch -D
- git 批量删除 tag
1. master分支存在大量冗余tag aa0e24dfd920a85c39da400a404309cb6fc69dc0 refs/tags/rc_69 f36f3f21f1ce61db3974e9 ...
随机推荐
- SQL 不同的数据类型
SQL 不同的数据类型 1.SQL TEXT 2.SQL VARCHAR(SIZE) VARCHAR(X) Case: user name, email, country, subject, pass ...
- 九度OJ 1056--最大公约数 1439--Least Common Multiple 【辗转相除法】
题目地址:http://ac.jobdu.com/problem.php?pid=1056 题目描述: 输入两个正整数,求其最大公约数. 输入: 测试数据有多组,每组输入两个正整数. 输出: 对于每组 ...
- PXE安装linux系统
利用网络安装系统流程:1.配置dhcp,让客户端能够自动获取ip,在dhcp配置中添加pxelinux.0配置,使客户端连接tftp文件2.复制光盘镜像的isolinux文件夹下面的所有文件到tftp ...
- DataGridView 绑定数据后修改列类型
dataGridView1.DataSource = dt; dataGridView1.Columns.RemoveAt(); //删除要被替换的列 DataGridViewLinkColumn l ...
- python27读书笔记0.3
#-*- coding:utf-8 -*- ##D.has_key(k): A predicate that returns True if D has a key k.##D.items(): Re ...
- opengl打开本地bmp图片绘制
注意bmp图片的格式问题,32位ARGB 或者24位RGB.你所采用的素材一定要注意是多少位的就用多少位的.否则会显示错误的图片或者其他什么的错误. 代码如下 32位版本 #include < ...
- Javascript的websocket的使用方法
javascript websocket接口 web实现客户端和服务端双向发送消息的方法有: 轮询,客户端定期向服务端请求: 长轮询,客户端定期向服务端请求,服务端只有有信息发送的时候才返回respo ...
- 【BZOJ】1044: [HAOI2008]木棍分割 二分+区间DP
链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1044 Description 有n根木棍, 第i根木棍的长度为Li,n根木棍依次连结了一起, ...
- 8位灰度图在LCD上显示
一.概述 1.灰度 灰度使用黑色调表示物体,即用黑色为基准色,不同的饱和度的黑色来显示图像.每个灰度对象都具有从 0%(白色)到灰度条100%(黑色)的亮度值. 使用黑白或灰度扫描仪生成的图像通常以灰 ...
- 6.MVC框架开发(文件上传)
1.需要设置表单的enctype="multipart/form-data"属性 2.在控制器中获取表单文件中数据 [HttpPost] public ActionResult A ...