Skip to content

Instantly share code, notes, and snippets.

@ADIX7
Last active August 5, 2019 13:13
Show Gist options
  • Save ADIX7/6ce50e4eb867410f7551824c76a6653a to your computer and use it in GitHub Desktop.
Save ADIX7/6ce50e4eb867410f7551824c76a6653a to your computer and use it in GitHub Desktop.
Tools
$localBranches = git branch --no-color --format="%(refname:short)" -l
$remoteBranches = git branch --no-color --format="%(refname:short)" -r
$branchSummary = ($localBranches | Where-Object { $remoteBranches -contains ("origin/" + $_)} | ForEach-Object {
$name = $_
[pscustomobject]@{name = "$name"; diff = git rev-list "$name...origin/$name" --oneline --left-right}
} | Where-Object {$_.diff.Length -gt 0} | ForEach-Object {
$name = $_.name
$incoming = ($_.diff | Where-Object { $_.StartsWith(">")}).Length
$outgoing = ($_.diff | Where-Object { $_.StartsWith("<")}).Length
[pscustomobject]@{name = "$name"; incoming = "$incoming"; outgoing = "$outgoing"}
})
# $branchSummary | ForEach-Object { git checkout $_.name ; git pull --ff-only}
$branchSummary | ForEach-Object { $_.name + ": " + $_.incoming + " incoming, " + $_.outgoing + " outgoing" }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment