LoginSignup
18
12

More than 1 year has passed since last update.

gitで変更箇所を文字単位で表示

Last updated at Posted at 2015-05-24

gitに同梱のdiff-highlightを使うことで、行単位から文字単位で変更を表示できる。

diff-highlightへPATHを通す。

Homebrewでgitを入れている場合

zsh,bashの場合

Intel Mac

$ export PATH=$PATH:/usr/local/share/git-core/contrib/diff-highlight

Apple Silicon

$ export PATH=$PATH:/opt/homebrew/opt/git/share/git-core/contrib/diff-highlight

fishの場合

Intel Mac

$ set -x PATH $PATH /usr/local/share/git-core/contrib/diff-highlight

Apple Silicon

$ set -x PATH $PATH /opt/homebrew/opt/git/share/git-core/contrib/diff-highlight

.gitconfigに設定を追加する

~/.gitconfig
log = diff-highlight | less
show = diff-highlight | less
diff = diff-highlig | less

結果

$ git diff Gemfile

1___tmux_turing_local__zsh__4_0____turing_local__tmux_.png

便利。

18
12
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
18
12