Git: cloning a git repository from one location to another

Most Git providers-as-a-service have administrative functions for renaming, moving, and even importing repositories from other provider URLs.

However, it is also valid to perform these operations manually by repointing the origin and then pushing all commits and tags to a new repository URL.

# make sure all changes are pushed first
git push
# check current remote origin
git remote -v
# make sure all historical commits are local (unlimited depth)
git pull --unshallow

# rename existing origin
git remote rename origin old-origin

# add URL to newly created, but empty repo
git remote add origin https://my.other.gitprovider.com/fabianlee/myNewProjectName.git

# push all history and tags
git push -u origin --all
git push -u origin --tags

When you are done, you can remove the old-origin.

git remote remove old-origin

# verify only new 'origin' exists
git remote -v

REFERENCES

somedevtips.com, changing remote repo URL