Start with a repo that has at least one commit (it contains a master / main branch).
For simplicity, make sure the new repo files are in a folder.
Add a remote for the repo to be merged:
git remote add -f another_repo
Merge the files into current repo master branch:
git merge another_repo/master --allow-unrelated-histories
Remove the remote for the added repo:
git remote remove another_repo
The history is now concatenated and the second repository can be deleted.
Create master branch locally with history from main:
git branch -m main master
Push master:
git push -u origin master
Sswitch HEAD:
git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/master
Change the default branch on GitHub to master under Settings > Branches > Default branch
Delete the main branch on the remote
git push origin --delete main