Based on this answer you can also use:
git diff previous_release..current_release -- . ':!spec'
This is a newish git feature which allows excluding certain paths. It should be more reliable than various shell oneliners.
I’m posting this here because this question is still the #1 hit for “git diff exclude path”.
Since Git 2.13 (Q2 2017), you can replace !
with ^
. The latter doesn’t need quotes. So you can write it as:
git diff previous_release..current_release -- . :^spec