I need to merge two Git repositories into a brand new, third repository. I followed the following instructions and they work, but the result is not what I
It's easy, instead of merging use rebase. Assuming you want to have repoA/master
first just do (after fetching and adding remotes)
# starting on master
git rebase RepoB/master # place master on top of masterB
git rebase RepoA/master # place master (with masterB) on top of masterA
Note that rebases are potentially destructive and a bit unintuitive at first, so I strongly recommend reading about them first (SO documentation in the link above is a good place to start)