简体   繁体   English

删除早于

[英]Delete inactive git branches older than

I have multiple repositories with a lots of old branches that were never deleted. 我有多个存储库,其中包含许多从未删除的旧分支。

Is there a way to search all branches that were not updated for a specified amount of time ? 有没有一种方法可以搜索在指定时间内未更新的所有分支?

I also want to add in that search if possible, branches that doesn't have commits ahead of master, to make sure nothing important is deleted. 我还想在可能的情况下添加搜索,即在master之前没有提交的分支,以确保没有重要的内容被删除。

At that point, I don't care if they were merged or not, 那时,我不在乎它们是否合并,

You can do what ever you wish. 您可以做任何您想做的事。

Here is a sample script which will print out all the branches with their last commit date (should be on a single line) 这是一个示例脚本,它将打印出所有分支以及它们的最后提交日期(应该在一行上)

for ref in $(git branch); 
    do git log -n1 $ref 
    --pretty=format:"%Cgreen%an%Creset %C(yellow)%d%Creset %C(bold blue)%cr%Creset%n" ; 
done | cat | sort -n -k1,1

It will print out all branches in a cool way so you can echo the $ref to file and delete them 它将以一种很酷的方式打印出所有分支,因此您可以将$ ref回显到文件并将其删除

在此处输入图片说明

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

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