This is basically a check-list on pushing entire local repository, with all branches, tags and entire history to brand new remote repository and changing default remote setting in local repostiory from one to another. A compilation of this and this answers on Stack Overflow plus some own thoughts. Gogs and GitHub are quite similar to each other and all operations an made on command-line, so you can use this article as an aid in migrating one remote repository to another.
1. Create new remote repository and pick correct owner, repo name etc.
2. Clone repository from current remote to your local machine, if you haven’t done this yet.
3. Rename current
origin remote to something else:
git remote rename origin upstream.
4. Add new remote as
git remote add origin git@URL:OWNER/REPO.git.
5. Push stuff to new remote:
- all branches:
git push origin --all,
- all branches:
git push origin '*:*'(details below list),
git push origin master.
6. Push all tags:
git push origin --tags (if your repository is using them).
7. Update tracking branch:
git branch --set-upstream-to=origin/master master.
8. Optionally remove
upstream remote, if you’re not going to use it:
git remote remove upstream.
9. Optionally (if you were using Gerrit previously) delete
/.git/hooks/commit-msg hook from each repository and from templates directory (
c:\Program Files (x86)\Git\share\git-core\templates\hooks on Windows) or else you’ll end nasty warnings about Change-Id.
Alternatively, you can push everything using one command (
git push origin --mirror). However, this will make a mirror copy and will also push all your remotes. Therefore this might not be exactly what you want.
If you are on Gogs, you can skip all of this and use migration tool (