Making git diff –stat show full file path

Question:

On doing git diff --stat some files are listed with full path from repository base but some files are listed as:

That is the path starts with ... and only short path is shown.

I would like git diff to list full file path for all files for it to be easily processed by a script. Is there some way I can get git diff to always show full path

Answer:

By default git diff truncates its output to fit into a 80-column terminal.

You can override this by specifying values using the --stat option:

For example, by setting the output value to a very large number:

Note that produces the path relative to the root of the git repository.

(For scripting you might want to use git diff-tree directly since it’s more of a “plumbing” command, although I suspect you’ll be fine either way. Note that you need the same extra text with --stat when using git diff-tree. The essential difference between using the git diff “porcelain” front end, and the git diff-tree plumbing command, is that git diff looks up your configured settings for options like diff.renames to decide whether to do rename detection. Well, that, plus the front end git diff will do the equivalent of git diff-index if you’re comparing a commit with the index, for instance. In other words, git diff reads your config and invokes the right plumbing automatically.)

Leave a Reply