git cli원격 저장소 브랜치 존재여부 체크

Circlee7
Oct 16, 2020

git 명령어로 원격저장소(origin)의 브랜치 존재여부를 체크하려한다.

적절해보이는 명령어를 찾아보았다.
git ls-remote

NAME
git-ls-remote - List references in a remote repository
SYNOPSIS
git ls-remote [--heads] [--tags] [--refs] [--upload-pack=<exec>]
[-q | --quiet] [--exit-code] [--get-url] [--sort=<key>]
[--symref] [<repository> [<refs>…​]]
DESCRIPTION
Displays references available in a remote repository along with the associated commit IDs.

원격 저장소에서 참조할수있는 것을 찾는다.

여러 옵션을 이용한 다양한 사용방법이 있는데.
— exit-code 옵션을 주어 브랜치 존재여부를 체크하는 배포스크립트를 작성해보았다.

--

--