コマンドからカレントブランチの WEB (GitHub など)ページを開く git-browse-remote が便利だったのでご紹介。
これ、某所の推奨 git alias に載っていたのですが、まったく使ってませんでした。
会社変わって、環境が変わったこともあって使ってみたら、非常に便利でした。
参考:
[alias]
br = browse-remote
pr = browse-remote --pr
これで、現在のブランチのページやプルリクを見に行ってます。
結構、プルリクページを開くのって手間ですよね。
git pr だけでジャンプできるのでとても楽になりました!
hub コマンドでもできる
同じことが hub コマンドでもできます。
こちらは GitHub をより便利に使うためのツールで、git-browse-remote よりも高機能です。
alias git=hub のように git コマンドを置き換えて使うことができ、通常の git コマンドよりも GitHub を便利に使えるようになります。
ドキュメント
hub コマンドの詳細は省略。
ページ開くのだけなら、git-browse-remote で十分です。
GitHub Enterprise に対応する
.gitconfig で下記のように GitHub Enterprise の URL を設定すれば OK です。
# GitHub 用の設定
[browse-remote "github.com"]
top = https://{host}/{path}
ref = https://{host}/{path}/tree/{short_ref}
rev = https://{host}/{path}/commit/{commit}
pr = https://{host}/{path}/pull/{short_ref}
file = "https://{host}/{path}/{file.directory? and :tree or :blob}/{short_rev}/{file}{lines && \"#L%s\" % lines.join(\"-\")}"
# GitHub Enterprise 用の設定
[browse-remote "hogehoge.github.jp"]
top = https://{host}/{path}
ref = https://{host}/{path}/tree/{short_ref}
rev = https://{host}/{path}/commit/{commit}
pr = https://{host}/{path}/pull/{short_ref}
file = "https://{host}/{path}/{file.directory? and :tree or :blob}/{short_rev}/{file}{lines && \"#L%s\" % lines.join(\"-\")}"