Help us understand the problem. What is going on with this article?

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

More than 5 years have passed since last update.

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にメソッド名を出すようにするにはプロジェクトルートに

*.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:

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした