How to overwrite a git repository(including all branches) to another git repository

Solution 1:

You are looking for the git branch command. Run this on the new repo after you fetched all branches from the original:

git branch --force master origin/master

This forces the local master branch to point to the same commit as the remote master branch.