LoginSignup
29
24

More than 5 years have passed since last update.

GitHub の Compare View で差分を見る (hub compare)

Posted at

https://github.com/:user/:repo/compare/:start...:end という URL を叩くと Compare View という画面になり、

  • :start から :end までのコミット
  • :start から :end までの diff
  • :start から :end までのコミットに対してつけられたコメント

が一覧できる。 :start, :end には commit の sha1 や master, HEAD などの名前、そしてタグが使える。 例: https://github.com/fastladder/fastladder/compare/2.3.5...master


master は不定なので、特定のコミット間の差を見たい場合は commit sha に置き換えたほうが安全。 git rev-parse master などとすると commit sha1 が得られる。

$ git rev-parse master
711ae09c3de07532c4ee86d7a8ffb08bfa6d369e

hub コマンドは Compare View を開く hub compare というサブコマンドがある。

   git compare [-u] [USER] [START...]END
          Open a GitHub compare view page in the system's default web browser. START to END are branch names, tag
          names,  or  commit SHA1s specifying the range of history to compare. If a range with two dots (a..b) is
          given, it will be transformed into one with three dots.  If  START  is  omitted,  GitHub  will  compare
          against the base branch (the default is "master").
$ hub compare 2.3.5...master

hub に :start, :end を渡すときに git rev-parse で commit sha1 を展開しておくと URL を操作する手間が省けて便利。あまりスマートではないが。

$ hub compare 2.3.5...`git rev-parse master`


hub http://defunkt.io/hub/

29
24
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
29
24