Skip to content

Instantly share code, notes, and snippets.

@stofte
Created June 28, 2018 11:08
Show Gist options
  • Save stofte/3bfecf22e99b514327e46313e7b47810 to your computer and use it in GitHub Desktop.
Save stofte/3bfecf22e99b514327e46313e7b47810 to your computer and use it in GitHub Desktop.
Powershell to print status of all listed branches, inclusing how far different branches are from master
@(
"https://tfs.kraftvaerk.com/tfs/KvCollection/CLEVER/_git/CLEVER.BillingEngine",
"https://tfs.kraftvaerk.com/tfs/KvCollection/CLEVER/_git/CLEVER.Connect",
"https://tfs.kraftvaerk.com/tfs/KvCollection/CLEVER/_git/CLEVER.CPMS",
"https://tfs.kraftvaerk.com/tfs/KvCollection/CLEVER/_git/NOC.Services",
"https://tfs.kraftvaerk.com/tfs/KvCollection/CLEVER/_git/NOC.Tools",
"https://tfs.kraftvaerk.com/tfs/KvCollection/CLEVER/_git/POI.Services",
"https://tfs.kraftvaerk.com/tfs/KvCollection/CLEVER/_git/CLEVER.APP",
"https://tfs.kraftvaerk.com/tfs/KvCollection/CLEVER/_git/CLEVER.AzureFunctions",
"https://tfs.kraftvaerk.com/tfs/KvCollection/CLEVER/_git/CLEVER.RELEASE",
"https://tfs.kraftvaerk.com/tfs/KvCollection/CLEVER/_git/CLEVER.Documentation"
) | foreach {
$Name = $_ -match '_git/(.*)$';
$outstr = '';
git clone "$_" 2> $null; # very noisy?
cd $matches[1];
write-host "`n`nCLONING $($matches[1])";
pwd;
git fetch --all;
git pull --all;
git checkout master 2> $null; #already on master
git branch --all | where { $_ -match "remotes/origin/"; } | foreach {
$_ -match 'remotes/origin/([^ ]*)';
$name = $matches[1];
$skipbranch = $name -eq "HEAD" -or $name -eq "master";
if (-not $skipbranch) {
write-host "`t$($name)";
git checkout $name 2> $null; # required?
# cherry pick for commits in $name, which is not in master somwhoe
git log master...$name --cherry --oneline | foreach { "`t`t$_"} | write-host
}
} | Out-Null
cd ..
}| Out-Null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment