清理本地git分支脚本 - 日理万妓 2023-01-16 11:22 70阅读 0赞 习惯使用命令行来操作git分支,久而久之会发现本地过多的不需要分支,影响筛选,所以写了段脚本清理本地分支,支持白名单跳过清理: 默认跳过当前分支,master、online分支 #!/usr/bin/python3 #coding:utf-8 import os # 白名单自动跳过 whiteList = [ "master" ] os.system("git branch > .branch") fileHandler = open(".branch", "r") while True: line = fileHandler.readline().strip() # print "branch:" + line if not line : break; if (line[0] == "*") or (line == "master") or (line == "online") or (line in whiteList): # print "pass:" + line continue; else: os.system("git branch -D {0}".format(line)) print(line.strip()) fileHandler.close() os.system("rm .branch")
还没有评论,来说两句吧...