/
Git diff side by side
Git diff side by side
How to get a side by side diff with git diff
or git difftool
in the terminal.
Alternative 1
Use icdiff
, as instructed on blog.scottnonnenberg.com/better-git-configuration
- install
icdiff
(from jeffkaufman/icdiff but ubuntu also has a package) - add to your
~/.gitconfig
:
[diff]
tool = icdiff
[difftool]
prompt = false
[difftool "icdiff"]
cmd = /usr/local/bin/icdiff --line-numbers $LOCAL $REMOTE
- use
git difftool ...
to use instead ofgit diff
, e.g.git difftool master
to compare current branch andmaster
.
Example output:
Alternative 2
Requirements:
- sdiff (from diffutils)
- colordiff
Place the following in your PATH (eg ~/bin/diffy
):
#!/bin/sh
echo
echo Comparing: "$1 between $3 and $6"
echo
if stty >/dev/null 2>&1; then
pager=${PAGER:-less -r}
else
pager=cat
fi
C=$(stty size | cut -d' ' -f2)
D=$(expr $C / 2)
sdiff -W -w $C "$2" "$5" | colordiff | grep -E "^.{$D} *[|<>] *" -A 10 -B 10 -n | $pager
Then set the environment variable GIT_EXTERNAL_DIFF
to point to it.
Example output:
, multiple selections available,
Related content
Developing with Bazel
Developing with Bazel
Read with this
Rando scripts
Rando scripts
More like this
Your first CockroachDB PR
Your first CockroachDB PR
Read with this
Contributing to CockroachDB
Contributing to CockroachDB
Read with this
Building from source on macOS
Building from source on macOS
Read with this
Copyright (C) Cockroach Labs.
Attention: This documentation is provided on an "as is" basis, without warranties or conditions of any kind, either express or implied, including, without limitation, any warranties or conditions of title, non-infringement, merchantability, or fitness for a particular purpose.