I use git diff --exit-code
to color my shell prompt so that I can see if there are diffs in the working copy. On very large repositories, this takes a very long time, as long as git diff
without the extra argument.
I had hoped that --exit-code
would cause git to exit as soon as it found the first difference, but in fact, it actually prints the diff. When run with --quiet
, it of course doesn't print the diff, but still takes equally long, which suggests it's still computing all the changes, even if not showing them.
So my question is: is there a way with git diff
(or any other git command) to simply check whether there are any diffs, and set an exit code accordingly, but without bothering to find and format all the actual changes?
Edit: For context on the size of the repo, it's about 7.5G (of which 4.1G is the .git/
dir), and ~160k tracked files.