If I do git diff
, I'll get the current changes of all unstaged files.
Is there a simpler way to automatically perform git diff
on just the first listed file (using the built in flags)?
The best I've come up with is:
function git_diff_first_unstaged_file() {
if [[ $(git diff --name-only) ]]; then
git diff $(git diff --name-only | sed -n '1 p')
else
echo "gdf: There are currently no unstaged changes."
fi
}
alias gdf='git_diff_first_unstaged_file'
I'm wondering if there is a git diff
flag I brushed over that would do this for me.