How to compare a local Git branch with its remote branch

git diff <local branch> <remote>/<remote branch>

For example, git diff main origin/main, or git diff featureA origin/next

Of course to have said remote-tracking branch you need to git fetch first; and you need it to have up-to-date information about branches in the remote repository.

Leave a Comment