I'm looking to translate this little bash function I have saved as the git tidy
alias to either PowerShell or cmd, so that it can be used across my Windows Terminal in both Windows and Linux Subsystem.
git branch --merged | grep -v \"\\*\" | xargs -n 1 git branch -d;
The script itself is detects any branches in the current git repo that have been merged into the currently checked-out branch (git branch --merged
), filters all branches not currently checked-out (| grep -v \"\\*\"
), and deletes them locally (| xargs -n 1 git branch -d
).
Obviously executing this command in something like PowerShell or cmd raises the error 'grep' is not recognized ...
. I don't know enough PowerShell or cmd scripting to be able to translate this command for use on either of the Windows shells.
What would the equivalent of the above command be for PowerShell and/or cmd?