How to do local git merges

I don't have much time to write today, so there won't be much of an explanation.
I think that is should be as easy as: "git merge repoA repoB" but it is-ain't. This seems like it should be included as basic functionality, but I couldn't find it. So I researched...
During my research, I encountered weirdness beyond the usual stackoverflow.com style "Why would you do that. Do something else instead." It was just weird. Git doesn't make sense. When you read git documentation, you will see what look like English words. They are not English words, or to be more precise, they don't have the English meanings. "git checkout" may as well be "git floobleflarg". I found most explainations culty. It is a vibe. It is like when people try to explain a word using ... that same word!
Here is a minimal script (without error checking, so make sure you understand it):
#!/bin/bash # Usage: peer-merge.sh A B [BRANCH] # git merge A to B. A=$(realpath "$1") B=$(realpath "$2") BRANCH="${3:-main}" cd "$B" git remote add peer-merge "$A" git fetch peer-merge git merge peer-merge/"$BRANCH" git remote remove peer-merge
This is a minimal script. It only works locally, but with some changes, it can work over a network too. My complete version works over a network...so you know it can be done.
Use the optional BRANCH arg if your main branch is named something else like "master" or "trunk".
So I did this and it changed my life.