Hugo

HOWTO migrate a Hugo project repo to another git provider

Sometimes the need arises to migrate to another git provider.
Here is a quick and safe way to do it:

1 . Create a new empty repository to the git provider of your choice.

  1. From the root of your local Hugo project remove the origin ref
git remote rm origin
  1. Add the new origin of the empty repo created in step 1.
git remote add origin <new-repo>
  1. Transfer everything to the new remote including all of the repo’s history with the --mirror flag
git push --mirror origin
  1. If you wish to delete your repo or even your entire account from the previous git provider now it’s safe to do just that.

P.S. I am sharing the above in light of GitLab’s announcement regarding the mandatory enforcement of telemetry for hosted repositories.

On a side note: The origin part of these commands is a convenience title. You can have as many remotes to any repository as you want. I have for instance a repo that is on Github an Bitbucket and has two removes (origin = github, bitbucket = well, bitbucket).

The commands git push origin and git push bitbucket then push to the respective repo. If you want to push to all remotes just use git push --all, that should post to both repos (I never tried, that’s why I say “should” :wink: