---
title: "删除 Git 中已经 merge 的 branch"
description: "你可以在 egrep -v 'master|develop|foo|bar' 里加上更多想保留的 branch"
canonical: https://oozou.com/til/delete-already-merged-branchs-in-git-36
locale: zh-Hans
date: 2020-10-13
topic: shell
---

# 删除 Git 中已经 merge 的 branch

> 你可以在 egrep -v 'master|develop|foo|bar' 里加上更多想保留的 branch

Published: 2020-10-13 · Topic: [shell](https://oozou.com/zh-Hans/til-topics/shell) ([markdown](https://oozou.com/zh-Hans/til-topics/shell.md))

```
$ git branch --merged | egrep -v 'master|develop' | xargs -n 1 git branch -d
```

你可以在 *egrep -v 'master|develop|foo|bar'* 里加上更多想保留的 branch

---

Contact OOZOU: hello@oozou.com · +66 2544 0000 · https://oozou.com/zh-Hans/contact

More for AI agents: https://oozou.com/llms.txt · every page has a markdown twin at its URL plus ".md"
