Created
January 29, 2025 06:22
-
-
Save book000/26dc541cf4ffbaecf8e6384df3e95ec8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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