LoginSignup
551
536

More than 5 years have passed since last update.

Git2.9のキレイなdiffを出すためのconfig

Last updated at Posted at 2016-06-15

Git 2.9 has been released
https://github.com/blog/2188-git-2-9-has-been-released

昨日キレイなDIFFが出せるgit2.9がリリースされました。
homebrewで brew upgrade git な感じでアップグレードすれば2.9は入るのですが、
このキレイなDIFFは標準では有効になってないので、記事にあるとおりに設定を行いましょう。
だいたい以下のような感じのコマンドうてばいいと思います。

下準備:diff-highlightにPATHを通す

まぁ通さずに直接読んでもいいんですが、通しておきましょう。
homebrewでいれるとdiff-highlightさんは↓あたりにいるのでPATHを通しておきましょう。

export PATH=$PATH:/usr/local/Cellar/git/2.9.0/share/git-core/contrib/diff-highlight
export PATH=$PATH:/usr/local/share/git-core/contrib/diff-highlight
修正: バージョン指定ではなく share を参照したほうがよいとのコメントいただきました。ありがとうございました。

いい感じの色になるやつ

$ git config --global pager.log 'diff-highlight | less'
$ git config --global pager.show 'diff-highlight | less'
$ git config --global pager.diff 'diff-highlight | less'

追記: git add -p ( git add --patch ) も対応させるには以下

$ git config --global interactive.diffFilter 'diff-highlight'

いい感じの差分になるやつ

$ git config --global diff.compactionHeuristic true

以上です。あとは普通に git diff すればキレイなDIFFが確認できて幸せやつ。

551
536
6

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
551
536