Is it possible to ask git diff to include untracked files in its diff output, or is my best bet to use git add on the newly created files and the e
For my interactive day-to-day gitting (where I diff the working tree against the HEAD all the time, and would like to have untracked files included in the diff), add -N/--intent-to-add is unusable, because it breaks git stash.
So here's my git diff replacement. It's not a particularly clean solution, but since I really only use it interactively, I'm OK with a hack:
d() {
if test "$#" = 0; then
(
git diff --color
git ls-files --others --exclude-standard |
while read -r i; do git diff --color -- /dev/null "$i"; done
) | `git config --get core.pager`
else
git diff "$@"
fi
}
Typing just d will include untracked files in the diff (which is what I care about in my workflow), and d args... will behave like regular git diff.
Notes:
git diff is really just individual diffs concatenated, so it's not possible to tell the d output from a "real diff" -- except for the fact that all untracked files get sorted last.git diff. If someone figures out how to do this, or if maybe a feature gets added to git at some point in the future, please leave a note here!