Tool
[git] 모든 branch (hotfix, feature, branch) 지우기
'김용환'
2017. 1. 3. 15:59
오랜 시간동안 사용 중인 git 프로젝트에는 정리하지 않은 branch(hotfix, feature, branch)이 존재한다.
이를 삭제하려면 2개의 과정이 필요하다.
1) 로컬 내부 저장소 깨끗이 정리하기
바로 삭제하려면, 아래와 같이 에러가 발생할 수 있다.
error: unable to delete 'aaa' remote ref does not exist
error: failed to push some refs to 'aa'
$ git fetch -p origin
2) 리모트 저장소 저장하기
hotfix 만 삭제하고 싶다면, 다음과 같이 실행한다.
$ git branch -r | grep hotfix | cut -d"/" -f2- | xargs git push origin --delete
만약 다른 feature도 함께 삭제하고 싶다면, 다음과 같이 실행한다.
$ git branch -r | grep -E '(feature,hotfix)' | cut -d"/" -f2- | xargs git push origin --delete