How to compare a local Git branch with its remote branch

Question

How can I see the diff between a local branch and a remote branch?

Answer

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.

How do I get git to default to ssh and not https for new repositories

Should composer.lock be committed to version control?