Skip to content

Instantly share code, notes, and snippets.

@book000
Created January 29, 2025 06:22
Show Gist options
  • Save book000/26dc541cf4ffbaecf8e6384df3e95ec8 to your computer and use it in GitHub Desktop.
Save book000/26dc541cf4ffbaecf8e6384df3e95ec8 to your computer and use it in GitHub Desktop.
git fetch --all
$remoteBranches = git branch -r --format='%(refname:short)'
$branches = git branch --format='%(refname:short)' | Where-Object { $_ -ne "" }
$branchTable = @()
foreach ($branch in $branches) {
$linkedRemote = git config --get branch.$branch.remote
if ($? -eq $false) {
$linkedRemote = $null
}
$linkedMerge = git config --get branch.$branch.merge
if ($? -eq $false) {
$linkedMerge = $null
}
else {
$linkedMerge = $linkedMerge -replace "refs/heads/", ""
}
if ($linkedRemote -eq "-" -or $linkedMerge -eq "-") {
$isExistRemote = $false
}
else {
$isExistRemote = $remoteBranches -contains "origin/$linkedMerge"
}
$branchTable += [PSCustomObject]@{
Branch = $branch
Remote = $linkedRemote
Merge = $linkedMerge
IsExistRemote = $isExistRemote
}
}
$branchTable | Format-Table -AutoSize
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment