`git diff` peut se faire plus précis pour repérer des changements au milieu de grandes lignes.
Git can compute finer diffs than the default line-by-line one. With --word-diff=color
it can highlight differences inside long lines.
$ git diff (1)
$ git diff --word-diff=color (2)
$ git diff --word-diff=color --word-diff-regex=.(3)
1 | Shows the default comparison between the known copy and the local work, line by line. |
2 | Shows only removed and added words (red for removed, green for added, by default). |
3 | Shows only removed and added letters. |
You can define aliases as shortcuts for the different git diff
options.
$ vi ~/.zshrc
alias wd='git diff --word-diff=color'
alias wd.='git diff --word-diff=color --word-diff-regex=.'
:wq
$ source ~/.zshrc
$ wd.
You can also configure git
to spend more time computing smaller and sharper diffs.
$ vi ~/.gitconfig
[diff]
algorithm = minimal
:wq