Select Page

Intro

Prefixes a/ and b/ represents source and destination file paths.

git diff man page: https://git-scm.com/docs/git-diff

It is typical to copy the file name with double-click select and paste or ctrl/cmd+click open directly in your favorite editor.

But, prefixes a/ and b/ come in between that and make the copy-pasting tedious.

Diff without a/ and b/ prefixes

git diff —no-prefix

# Output:
# diff --git info.md info.md
# index 2e5ce4d..fa12dad 100644
# --- info.md
# +++ info.md
# @@ -1,3 +1,5 @@
# # Git Diff
# Git diff is a powerful handy tool to see the code diff changeset.
# +
# +Some more info on Git.

Make no prefix a global default for all repos

Add it to global git config:

git config --global diff.noprefix true

Make no prefix a repo-specific default

Add it to local git config:

git config diff.noprefix true

Need a different prefix

git diff --src-prefix=""src: "" --dst-prefix=""dst: ""

This adds the desired prefix and still helps with copy-pasting file names.