本文翻译自:Remove tracking branches no longer on remote
Is there a simple way to delete all tracking branches whose remote equivalent no longer exists? 有一种简单的方法可以删除所有不再具有远程等效项的跟踪分支吗?
Example: 例:
Branches (local and remote) 分支机构(本地和远程)
- master 主
- origin/master 起源/主人
- origin/bug-fix-a 起源/错误修复
- origin/bug-fix-b 原点/错误修复-b
- origin/bug-fix-c 原点/错误修复-C
Locally, I only have a master branch. 在本地,我只有一个master分支。 Now I need to work on bug-fix-a , so I check it out, work on it, and push changes to the remote. 现在,我需要处理bug-fix-a ,所以我将其检出,对其进行处理,然后将更改推送到远程计算机。 Next I do the same with bug-fix-b . 接下来,我对bug-fix-b进行同样的操作 。
Branches (local and remote) 分支机构(本地和远程)
- master 主
- bug-fix-a 错误修复
- bug-fix-b 错误修复-b
- origin/master 起源/主人
- origin/bug-fix-a 起源/错误修复
- origin/bug-fix-b 原点/错误修复-b
- origin/bug-fix-c 原点/错误修复-C
Now I have local branches master , bug-fix-a , bug-fix-b . 现在我有了本地分支master , bug-fix-a , bug-fix-b 。 The Master branch maintainer will merge my changes in