git diff <branchname1>..<branchname2>
Show the difference between the contents of two branches
Like with many other git commands, you can replace branchnames with commit hashes to get a diff between the two commits:
git diff <commitA>..<commitB>
You can send the results of the command to a file for later use in a git patch
operation, like this:
git diff <branchname1>..<branchname2> > <filepath>
Specific examples:
git diff main..my-feature-branch