简体   繁体   English

如何清除Windows上的远程和本地git分支

[英]How do I clean both remote and local git branches on windows

删除不再存在的分支引用并删除Windows命令提示符下已为git repos合并的本地分支的最佳方法是什么(即不使用bash)?

This will first remove any remote tracking references that no longer exist and then proceed to enumerate and remove already merged local branches. 这将首先删除不再存在的任何远程跟踪引用,然后继续枚举并删除已合并的本地分支。 The exception is that current, develop and master branches will be kept. 唯一的例外是将保留当前分支,开发分支和主分支。

git fetch -p && for /f "tokens=1,2" %b in ('git branch --merged ^| findstr /v /c:"master" /c:"develop" /c:"*"') do (git branch -d %b)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM