A small script to find stale branches
#!/bin/bash | |
# This is a very naive script, it doesn't do grouping and returns all branches | |
# I only really care about branches that have not seen commits in two months | |
# | |
# I am hoping to find some time to write a tool that can output these reports for me | |
# In the meantime, I am using this | |
echo "Merged branches" | |
for branch in `git branch -r --merged | grep -v HEAD`;do echo -e `git log --no-merges -n 1 --format="%ci, %cr, %an, %ae, " $branch | head -n 1` \\t$branch; done | sort -r | |
echo "" | |
echo "Not merged branches" | |
for branch in `git branch -r --no-merged | grep -v HEAD`;do echo -e `git log --no-merges -n 1 --format="%ci, %cr, %an, %ae, " $branch | head -n 1` \\t$branch; done | sort -r |
This comment has been minimized.
This comment has been minimized.
Could you please suggest me how to list all the branches under enitirr gitlab |
This comment has been minimized.
This comment has been minimized.
It's a good idea to change the column separators because the dates in the output contain |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This comment has been minimized.
Quickly hacked together a powershell version in case it helps anyone
`#! /usr/bin/pwsh
echo ""
echo "Not merged branches"
$branches = git branch -r --no-merged | grep -v HEAD
$output = @()
foreach( $branch in $branches ) {
$branch = $branch.Trim()
$output += git log -n 1 --format="%ci, %cr, %an, %ae, $branch" --no-merges --first-parent $branch | Sort-Object
}
echo $output`