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:
diff.mnemonicprefix
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 diff
compares the (i)ndex and the (w)ork tree;
git diff HEAD
compares a (c)ommit and the (w)ork tree;
git diff --cached
compares a (c)ommit and the (i)ndex;
git diff HEAD:file1 file2
compares an (o)bject and a (w)ork tree entity;
git diff --no-index a b
compares two non-git things (1) and (2).
I still don't understand what this means. Can someone explain?
As mentioned in the diff man page, a/ and b/ represent the prefix to differentiate source and destination. Actually, you have the options: --no-prefix. Do not show any source or destination prefix.
The git diff HEAD [filename] command allows you to compare the file version in your working directory with the file version last committed in your remote repository. The HEAD in the git command refers to the remote repository.
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 a/
and b/
on the three lines I have indicated with arrows. This is non-mnemonic; the characters a
and b
have no real significance.
With 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 i
and w
are used to indicate your index and working copy respectively.
The other cases listed in the documentation work similarly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With