상세 컨텐츠

본문 제목

Github Tool (hub)

Development

by chbae 2023. 4. 19. 16:55

본문

728x90
반응형

github를 사용할 때 유용한 Tool인 hub에 대해 소개하도록 한다.

 

Homepage: https://hub.github.com/

 

hub · an extension to command-line git

Designed for open-source maintainers Maintaining a project is easier when you can easily fetch from other forks, check out pull requests, close issues, and even cherry-pick commits by URL. hub fetch mislav,cehoffman → git remote add mislav git://github.c

hub.github.com

hub 명령어는 git 명령어에 github에서 제공하는 API를 함께 사용할 수 있는 툴이다.

 

요구사항

  • git 1.7.3 이상
  • ruby 1.8.6 이상

설치 (홈페이지 첫장에 있는 설명이다.)

# OS X: install latest revision  
$ brew install hub  
# Other platforms: fetch a precompiled binary release, or  
# build your own from source. You'll need a Go development environment.  
$ git clone https://github.com/github/hub.git  
$ cd hub  
$ script/build  
$ mv ./hub ~/bin # ← move to somewhere in your PATH  
# alias it as git  
$ alias git=hub  
$ git version  
git version 2.1.4  
hub version 2.2.0 # ← it works!

~/bin을 ~/.bashrc에서 PATH로 잡아주면 어디서든 이용 가능하다.

export PATH=~/bin:$PATH

 

이렇게 하면 git 명령어를 치면 hub로 alias로 되어 있기 때문에 알아서 hub를 사용하게 된다. git의 모든 명령어가 호환되기 때문에 걱정하지 않아도 된다.

 

기본 사용법

  1. hub clone meta-gir - 최초로 github에 계정을 로그인하게 하고, 이 정보를 ~/.config/hub에 저장하기 이후부터는 로그인이 필요없다. 단 OAuth 토큰 정보를 저장하기 때문에 이 파일을 잘 관리 해야한다.
    - github 계정의 meta-gir repo를 clone한다.
  2. hub remote add locust2001
    - locust2001 계정의 현재 작업중인 repo이름을 remote add로 추가한다.
  3. hub cherry-pick https://github.com/meta-gir/meta-gir/commit/50f8e35e10259077cccaf8c03c5f7636c83a7395 
    - 관련 commit을 cherry-pick 한다. 아래는 github에 특화된 명령어이다.
GitHub Commands:  
   pull-request  Open a pull request on GitHub  
   fork      Make a fork of a remote repository on GitHub and add as remote  
   create     Create this repository on GitHub and add GitHub as origin  
   browse     Open a GitHub page in the default browser  
   compare    Open a compare page on GitHub  
   ci-status   Show the CI status of a commit

이 외에도 hub fork, hub pull-request, hub checkout, hub create, hub push, hub browse, hub compare등과 같은 많은 명령어가 있다.

 

github를 사용하는 개발자들에게 정말 추천하는 툴이다.

728x90

관련글 더보기