git merge

In case you haven’t noticed yet, I think git merge is sometimes overused. I like to keep commits organized and hygenic. A rule of thumb for doing this is to only use git merge if the merge will be a fast-forward merge. Otherwise this kind of thing can happen:

Let’s say you’ve got a few commits in your me/feature branch, and you’re missing a commit from your mainline.
main
A
B
me/feature
A
F
G

Ok, so you decide to use git merge.
git fetch --all
git checkout me/feature
git merge origin/main
Oops, now you have this weird situation. There’s a “merge” commit at the top of your branch and the branches look even more different now. That’s confusing! Furthermore, when you go to integrate your changes (assuming you don’t rebase or squash them first) into the main branch (when they’re ready for deployment or distribution or whatever), your main branch will also inherit this wonky merge commit. Do you find this awkward and noisy?
main
A
B
me/feature
A
F
G
Merge branch "main" into me/feature

So try to use git merge as little as possible.

How can you tell how two git branches differ?
If you want to see the difference in commits between two branches or commits, use git show-branch.