git remove local & remote branch
Delete all remote branches of remote {origin} except branch containing 'master'.
But when I run this command on my MacBook , it doesn't work because of the special characters '?]m'.
I searched that char and found it's the expression of ^M (ctrl + C then ctrl + M)
and tried to replace it like sed 's/^M//g' or sed 's/?]m//g', but it doesn't work.
So I did it on my another pc installed centOS.
+++
I found how to do it in my MacBook. I asked my friend whether it works on her MacBook, and she said it works.
Then I found 'format' option. and it works on my laptop.
git branch --format='%(refname:short)' | grep -v master | xargs git push origin --delete
git branch --format='%(refname:short)' | grep -v master | xargs git branch -D
+++
get remote branches
# git branch -r | grep -v '\->' | while read remote; do git branch --track "${remote#origin/}" "$remote"; done
remove remote branches
# git branch | grep -v master | xargs git push origin --delete
remote local branches
# git branch | grep -v master | xargs git branch -D
In shortly,
git branch -r | grep -v '\->' | while read remote; do git branch --track "${remote#origin/}" "$remote"; done
git branch | grep -v master | xargs git push origin --delete
git branch | grep -v master | xargs git branch -D
git branch 삭제하기 삭제
+ 한글로 쓸걸 괜히 영어로 쓰니까 나중에 보니까 금방 눈에 안들어온다. 됴륵