16
14

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Githubのpull-requestみたいなdiffを出力する

Last updated at Posted at 2014-03-17

Githubのpull-request時のdiffは、例えば
master <- hotfix
というpull-requestを行うとき、hotfixブランチで行った追加・削除分のみの差分が表示されます。
例: https://github.com/rails/rails/pull/14400/files

これをgitでどうやるのかなと調べてみたら見つかった。
上記のhotfixとmasterの例なら

$ git diff master...hoge

でいける。

追記
勘違いで間違ったコマンド貼ってたようです。
正確には...を使う方が正しいです。

git help diffから引用

git diff [--options] <commit>...<commit> [--] [<path>...]
   This form is to view the changes on the branch containing and up to the second <commit>, starting at a common ancestor of both <commit>. "git diff A...B" is equivalent to "git diff $(git-merge-base A B) B". You can omit any one of
   <commit>, which has the same effect as using HEAD instead.

git-merge-base A Bというのは、AとBの共通の先祖を探してくれるらしいです。gitまだまだおくがふかい。

16
14
2

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
16
14

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?