I simply want to get a non-zero exit code if there is a diff between a local branch and the remote tracking branch.
For example, say the local branch is foo, and I have it checked out, so the diff command would be:
git fetch origin
git diff --exit-code remotes/origin/foo
However, my question is - is there a generic/programmatic way to run this kind of diff command for any local branch? I want to diff a local branch with the remote tracking branch, generically.