---
title: "ลบ branch ที่ merge ไปแล้วใน Git"
description: "อยากกัน branch ไหนไว้ไม่ให้ถูกลบ ก็เพิ่มชื่อลงใน egrep -v 'master|develop|foo|bar' ได้เลย"
canonical: https://oozou.com/til/delete-already-merged-branchs-in-git-36
locale: th
date: 2020-10-13
topic: shell
---

# ลบ branch ที่ merge ไปแล้วใน Git

> อยากกัน branch ไหนไว้ไม่ให้ถูกลบ ก็เพิ่มชื่อลงใน egrep -v 'master|develop|foo|bar' ได้เลย

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

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

อยากกัน branch ไหนไว้ไม่ให้ถูกลบ ก็เพิ่มชื่อลงใน *egrep -v 'master|develop|foo|bar'* ได้เลย

---

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

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