Last Updated: February 25, 2016
·
2.335K
· borisguery

Always remove prefix when using git diff

When using the default git diff command it may be annoying to get the prefixed source file name:

diff --git a/config.yml b/config.yml
index cf3190e..8f0759d 100644
--- a/config.yml
+++ b/config.yml

git adds a a and b prefix and copy/paste selection isn't easy.

You can disable this default behavior by setting the following options to true:

git config --global --bool diff.noprefix true

Running git diff will now look like:

diff --git config.yml config.yml
index cf3190e..8f0759d 100644
--- config.yml
+++ config.yml

If you want to only remove the prefix occasionally, you can run git diff --no-prefix