Skip to content

Instantly share code, notes, and snippets.

@MrJerB
Created December 10, 2018 15:05
Show Gist options
  • Save MrJerB/13993847c1af5192eb2e87824f69b7c7 to your computer and use it in GitHub Desktop.
Save MrJerB/13993847c1af5192eb2e87824f69b7c7 to your computer and use it in GitHub Desktop.
Powershell dev cleanup helpers
function CleanBinObj {
Get-ChildItem .\ -include bin, obj -Recurse | ForEach-Object ($_) { remove-item $_.fullname -Force -Recurse }
}
Set-Alias Clean-BinObj CleanBinObj -Option AllScope
function CleanGitMergedMaster {
git checkout master;
git branch --merged |
ForEach-Object { $_.Trim('*', ' ') } |
Where-Object { ($_ -ne 'master') -and ($_ -ne 'develop') } |
ForEach-Object { git branch -d $_ }
}
Set-Alias Clean-GitMergedMaster CleanGitMergedMaster -Option AllScope
function CleanGitMergedMaster {
git checkout master;
git branch --merged |
ForEach-Object { $_.Trim('*', ' ') } |
Where-Object { ($_ -ne 'master') -and ($_ -ne 'develop') } |
ForEach-Object { git branch -d $_ }
}
Set-Alias Clean-GitMergedMaster CleanGitMergedMaster -Option AllScope
function CleanGitNoRemote {
git checkout master;
git branch -vv |
Where-Object { $_ -match '\[origin/.*: gone\]' } |
ForEach-Object { $_.Split(" ", [StringSplitOptions]'RemoveEmptyEntries')[0] } |
ForEach-Object { git branch -d $_ }
}
Set-Alias Clean-GitNoRemote CleanGitNoRemote -Option AllScope
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment