Skip to content

Instantly share code, notes, and snippets.

@tkalve
Created December 22, 2025 17:30
Show Gist options
  • Select an option

  • Save tkalve/755ecedf052a79697ca511a4e3aaf1d3 to your computer and use it in GitHub Desktop.

Select an option

Save tkalve/755ecedf052a79697ca511a4e3aaf1d3 to your computer and use it in GitHub Desktop.
List recently updated Git branches
<#
.SYNOPSIS
Display recently updated git branches in a formatted table.
.DESCRIPTION
Shows the most recently updated local branches with details including
branch name, last commit date, author and message.
.PARAMETER Count
Number of branches to display. Default is 15.
.EXAMPLE
.\git-recent-branches.ps1
Shows the 15 most recently updated branches.
.EXAMPLE
.\git-recent-branches.ps1 -Count 5
Shows the 5 most recently updated branches.
.NOTES
To create a git alias for this script, add the following to your .gitconfig:
[alias]
recent = "!f() { pwsh ~/scripts/git-recent-branches.ps1 \"$@\"; }; f"
Then use it as:
git recent # shows 15 branches (default)
git recent 5 # shows 5 branches
git recent 25 # shows 25 branches
#>
param(
[int]$Count = 15
)
git for-each-ref --sort=-committerdate `
--count=$Count `
--format='%(refname:short)|%(committerdate:relative)|%(authorname)|%(contents:subject)' `
refs/heads/ |
ForEach-Object {
$cols = $_ -split '\|',4
[pscustomobject]@{
'Branch name' = $cols[0]
'Last commit' = $cols[1]
'Author' = $cols[2]
'Message' = $cols[3]
}
} | Format-Table -AutoSize
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment