I found the following command in a shell script:
git diff-index --quiet HEAD --; What does this command mean/do?
It can be used to help determine whether there are any changes in a working tree by comparing your working tree to the HEAD revision. The --quiet means to silence the output and alter the exit code based on whether the tree is modified (exits with 1) or is not modified (exits with 0). The -- is used to separate paths from the rest of the argument. This helps Git know that HEAD is actually the name of a treeish, rather than confuse it with the name of a file should a file called HEAD exist in your tree.
The short form: if the script is using set -e, then the script will exit with an error if your working tree has changes in it.
git diff --quiet, though?git diff is a porcelain command whereas git diff-index is plumbing. You could probably get by with using git diff here if you really wanted to though.git diff-index --quiet HEAD -- instead of git diff --quiet, other than a predilection for plumbing over porcelain? (The latter was added in Git 1.5.1, so they're both nearly as old as Git itself.)git diff-index being a plumbing command, no I don't know of any other reason to chose it over git diff in this case. There's no performance benefit or the like since git diff essentially calls git diff-index under the hood in this case.
git help diff-index.