What does diff.mnemonicprefix do?
I’ve noticed that SourceTree performs git commands with this configuration option:
git -c diff.mnemonicprefix=false
This is what the git docs say about this option:
If set, git diff uses a prefix pair that is different from the standard “a/” and “b/” depending on what is being compared. When this configuration is in effect, reverse diff output also swaps the order of the prefixes:
git diffcompares the (i)ndex and the (w)ork tree;
git diff HEADcompares a (c)ommit and the (w)ork tree;
git diff --cachedcompares a (c)ommit and the (i)ndex;
git diff HEAD:file1 file2compares an (o)bject and a (w)ork tree entity;
git diff --no-index a bcompares two non-git things (1) and (2).
I still don’t understand what this means. Can someone explain?
One Solution collect form web for “What does diff.mnemonicprefix do?”
git diff shows some metadata about the files it is comparing. Ordinarily you might see something like this:
diff --git a/foo/bar.txt b/foo/bar.txt <-- index abcd123..1234abc 100644 --- a/foo/bar.txt <-- +++ b/foo/bar.txt <--
Note how the files are differentiated using
b/ on the three lines I have indicated with arrows. This is non-mnemonic; the characters
b have no real significance.
diff.mnemonicprefix enabled, these characters are chosen as described in the documentation you quoted. For example, if you have changes to your local copy and are comparing against the index (e.g. with
git diff) you would see something like
diff --git i/foo/bar.txt w/foo/bar.txt index abcd123..1234abc 100644 --- i/foo/bar.txt +++ w/foo/bar.txt
instead. The characters
w are used to indicate your index and working copy respectively.
The other cases listed in the documentation work similarly.