I have a git repo with tens of remotes which have been merge
You may need to prune your local "cache" of remote branches first. Try running:
git fetch -p origin
before deleting.
Are those branches removed from the remote (origin)? If yes, you can simply do
git fetch --prune origin
Otherwise they might return even after you delete them locally.
Update: Looking at your command again, it looks like you're building it incorrectly. You probably want
git push origin --delete myBranch-1234
but instead you are doing something like
git push origin --delete origin/myBranch-1234
Use sed
to remove 'origin/' part and change a lttile xargs
part.
git branch -r --merged | grep origin | grep -v -e master | sed s/origin\\/// | xargs -I{} git push origin --delete {}