244
244

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.

gitのdiffを見やすく表示する

Last updated at Posted at 2013-11-21

GitHubのdiffがメソッド名表示されて見やすかったので、ローカルでも出来ないか調べたのでそのメモ。

例えばGitHubのdiffはメソッド名def is_repo?が出る
Screen Shot 2013-11-21 at 7.17.20 PM.png
https://github.com/github/hub/commit/87050ce94a97b0c382b99c975bde0c833332b38e

普通にしてるときのローカルのdiffはこんなかんじ。メソッド名出ない:confounded:
Screen Shot 2013-11-21 at 7.20.04 PM.png

ローカルでもGitHubのようにdiffにメソッド名を出すようにするにはプロジェクトルートに

.gitattributes
*.rb diff=ruby

を置けば:ok_hand:

ローカルはこんなかんじなる:heart_eyes:
Screen Shot 2013-11-21 at 7.29.07 PM.png

diffで選択できるパターンは
http://git-scm.com/docs/gitattributes#_defining_a_custom_hunk-header
に掲載されているので、必要に応じて変える。

2013/11/22 13:40 追記

グローバルな.gitattributesを指定したい場合は

~/.gitconfig
[core]
      attributesfile = ~/.gitattributes_global
~/.gitattributes_global
*.rb diff=ruby

のように設定すれば:ok_hand:

244
244
1

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
244
244

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?