TL;DR
My question is: how do I get my local git merge behavior to resemble the way it works when I do a pull request from a branch back to main in GitHub, i.e. showing a branched commit history rather than a rebase-like history? I don't have it set to automatically do anything with rebase from what I can tell -- see details below.
Here's the scenario:
- The
mainbranch is clean. - I perform
git checkout -b test-branch. - I make a change to README.md; check in, publish branch to origin.
- Another change to README.md; check in; repeat two more times (3 total local commits), push to origin. Here's what git graph shows:

- Switch to main; merge test-branch from VS code menu:

Then push to origin. Here's what git graph shows now:
The result looks like a single line of commits as if it did a rebase (which I don't want). - Now I repeat steps 1 through 4 creating a new branch
test-branch1. Here's what git graph shows:
- Now, instead of merging the branches locally, I perform a pull request from the branch in GitHub:

- Locally, I switch to main and pull from remote. Here's what git graph now shows:

Now instead of looking like a rebase happened, it has a separate history.
My user gitconfig just has my name and email address, and here is what my repo git config looks like (i.e. no rebase setting from what I can tell):
So again, my question is how do I get my local merge behavior to resemble the way it works when I do a pull request from a branch back to main in GitHub, i.e. maintaining the separate commit history from the branch?

--no-ffflag in git prevents the execution of a "fast-forward" merge and it's the merge method that GitHub uses in pull requests. - reference.You might consider
--ff-onlyflag as well.