If this is for a script, you can use:
git fetch
$(git rev-parse HEAD) == $(git rev-parse @{u})
(Note: the benefit of this vs. previous answers is that you don't need a separate command to get the current branch name. "HEAD" and "@{u}" (the current branch's upstream) take care of it. See "git rev-parse --help" for more details.)