Listing each branch and its last revision's date in Git

后端 未结 11 752
傲寒
傲寒 2020-11-29 15:07

I need to delete old and unmaintained branches from our remote repository. I\'m trying to find a way with which to list the remote branches by their last modified date, and

11条回答
  •  再見小時候
    2020-11-29 15:46

    In PowerShell, the following shows branches on the remote that are already merged and at least two weeks old (the author:relative format starts displaying weeks instead of days at two weeks):

    $safeBranchRegex = "origin/(HEAD|master|develop)$";
    $remoteMergedBranches = git branch --remote --merged | %{$_.trim()};
    git for-each-ref --sort='authordate:iso8601' --format=' %(authordate:relative)%09%(refname:short)' refs/remotes | ?{$_ -match "(weeks|months|years) ago" -and $_ -notmatch "origin/(HEAD|master|qa/)"} | %{$_.substring($_.indexof("origin/"))} | ?{$_ -in $remoteMergedBranches}
    

提交回复
热议问题