GitHub CLI - gh
brew install ghwinget install --id GitHub.cli-
패키지 목록 업데이트 및 필수 도구 설치
Terminal window sudo apt updatesudo apt install curl -y -
GitHub CLI 공식 GPG 키 및 저장소 등록
Terminal window type -p curl >/dev/null || sudo apt install curl -ycurl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \&& sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages/deb stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null -
패키지 설치
Terminal window sudo apt updatesudo apt install gh -y
gh --version- 로그인 명령 실행
Terminal window gh auth login GitHub.com선택HTTPS또는SSH중 사용할 프로토콜 선택Login with a web browser선택- 터미널에 출력된 one-time code를 복사
- 안내되는 브라우저 페이지에 접속하여 코드 입력 후 인증 완료
- 로그인 상태 확인
Terminal window gh auth status
repo clone
Section titled “repo clone”- 저장소를 클론한다.
Terminal window gh repo clone ${OWNER}/${REPOSITORY} - 브라우저에서 저장소 페이지를 연다.
Terminal window gh repo view --web
pr create
Section titled “pr create”- 현재 브랜치를 push한 상태에서, 현재 브랜치 기준으로 PR을 생성한다.
Terminal window gh pr create --title "${TITLE}" --body "${BODY}" - 제목/본문 입력 없이 대화형 프롬프트로 생성하려면 옵션 없이 실행한다.
Terminal window gh pr create - 초안(draft) 상태로 생성한다.
Terminal window gh pr create --draft
pr list / view
Section titled “pr list / view”- 현재 저장소의 PR 목록을 조회한다.
Terminal window gh pr list - 특정 PR을 브라우저에서 연다.
Terminal window gh pr view ${PR_NUMBER} --web - 현재 브랜치에 연결된 PR 상태를 터미널에서 확인한다.
Terminal window gh pr status
pr checkout / merge
Section titled “pr checkout / merge”- 다른 사람이 올린 PR을 로컬로 가져와서 확인한다.
Terminal window gh pr checkout ${PR_NUMBER} - 리뷰가 끝난 PR을 병합한다. (
--squash,--rebase도 사용 가능)Terminal window gh pr merge ${PR_NUMBER} --merge
issue list / create
Section titled “issue list / create”- 이슈 목록을 조회한다.
Terminal window gh issue list - 새 이슈를 생성한다.
Terminal window gh issue create --title "${TITLE}" --body "${BODY}"