Git merge 2 repositories in 1 repository

This is a piece of code that I definetelly had to publish. It is very helpful if you need to merge 2 Git repositories in 1 repository. Note that at the end each of the repositories will be embeded in a separate folder.
mkdir migration
cd migration
git init
git remote add origin <final_repository>
echo "Luis Felipe Farfan" >> contributors.txt
git add contributors.txt
git commit -m 'Initial commit in the repository'
git push -u origin master
git remote add -f repo_a <git_repository_a>
git fetch repo_a
git branch tempo_repo_a repo_a/master
git checkout tempo_repo_a
mkdir repo_a
git ls-tree -z --name-only HEAD | xargs -0 -I {} git mv {} repo_a/
git commit -m "Moved files to repo_a/"
git checkout master
git merge tempo_repo_a
git remote add -f repo_b <git_repository_b>
git fetch repo_b
git branch tempo_repo_b repo_b/master
git checkout tempo_repo_b
mkdir repo_b
git ls-tree -z --name-only HEAD | xargs -0 -I {} git mv {} repo_b/
git commit -m "Moved files to repo_b/"
git checkout master
git merge tempo_repo_b
git push origin master
rm -rf contributors.txt
git commit -am"Removed initial commit in the repository"
git push origin master