Git・Gihubをより強力にするためのCLIツールについて説明します。
目次
- gh
- hub
- github-todos
- git-extras
- gitsh
- git-open
gh
hub
hubのドキュメントにも書いてあるのですがhubをgitのコマンドのエイリアスにすると既存のgitのコマンドを強力にできて便利です。
# alias作成
$ alias git=hub
# 確認
$ git --version
git version 2.2.0
hub version 1.12.2
Github URL: https://github.com/github/hub
github-todos
簡単にコードに書かれたTODOをGithubのissueに登録できる
Github URL: https://github.com/naholyr/github-todos
インストール
$ npm install -g github-todos
認証
$ [sudo] github-todos config github.token <your token>
$ github-todos auth
No token found to access Github API. I will now ask for your username and password to generate one.
Those information ARE NOT STORED, only the generated token will be stored in your global git configuration.
If you don't want to let this process go you'll have to generate a token yourself and then save it with 'github-todos config github.token <your token>'.
? Github username: <your username>
? Github password: <your password>
Connection to Github API succeeded
init
$ github-todos init
[Github-Todos] To disable checking credentials on 'init', add option '--no-connect'
[Github-Todos] Hook file not found, create new one…
[Github-Todos] Hook installed
[Github-Todos] Option 'repo' is not set
[Github-Todos] Now guessing initial configuration from remote 'origin'…
[Github-Todos] Will use repository '<your repository>'
[Github-Todos] Run 'github-todos config' to check configuration, you may want to customize 'repo' option
[Github-Todos] OK
確認
$ github-todos config
github.token = <your github token>
repo = <your repository>
はまったところ
問題
pushできない:
$git push
TypeError: Cannot read property 'content' of undefined
error: failed to push some refs to 'git@github.com:<your username>/<your repository>.git'
解決策
最初からやりなし
git-extras
gitのデフォルトにはないがよく使うコマンドを追加してくれるもの
Github URL: https://github.com/tj/git-extras
gitsh
毎日のように、$ git ~
と入力するのはも面倒なのでそれを解決するのが、gitshです。また既存のaliasなどもこのなかで使用することが可能です。
使い方
$ mkdir test && cd $_
$ touch README.md
$ gitsh
gitsh 0.8
Type :exit to exit
test uninitialized!! ⏎
fatal: Not a git repository (or any of the parent directories): .git
# git init
test uninitialized!! init
Initialized empty Git repository in /Users/sota/Desktop/test/.git/
test master! ⏎
On branch master
Initial commit
Untracked files:
README.md
nothing added to commit but untracked files present
# git add .
test master! add .
# git commit -m 'Create README'
test master& c 'Create README'
[master (root-commit) 381e857] Create README
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 README.md
test master@ ^D
インストール
$ brew tap thoughtbot/formulae
$ brew install gitsh