Migrating Git Repos

I feel the need to migrate all my github stuff to somewhere else. Because Microsoft is buying Github.
Gitlab does not seem to be that much different.

In the end, I chose two providers: framagit.org and notabug.org - just to be on the safe side.

The migration itself happened via web interface and isn't that interesting, but let it be noted that:

  • gitlab (the software used on framagit) allows to import all github repos, but they're all set to private (which is a good thing I guess) and have to be set to public manually, one by one.
  • on gogs (the software used on notabug) I have to import projects one by one, but tehy are automatically set to be public.

In the end, it's the same amount of work.

Now my workflow is such that I code on my own machine, then commit & push to the remotes (that was github so far) via ssh.

What do I need to change to push to the new remotes, and always push to both so they stay in sync?

Here's a bit of shell scripting that will do the most necessary stuff (always check what the command would do first - I have included some commands that do just that):

sh
cd /base/dir/where/all-my-git-repos-are grep -rm1 'notabug.org/ohnonot' # let's see which README's etc. conatin that sed 's#notabug.org/ohnonot#notabug.org/ohnonot#g' $(grep -lrm1 --exclude-dir=.git 'notabug.org/ohnonot') # testing to see what would be changed sed -i 's#notabug.org/ohnonot#notabug.org/ohnonot#g' $(grep -lrm1 --exclude-dir=.git 'notabug.org/ohnonot') # do it! grep -r 'notabug.org/ohnonot' # let's see if it worked ##### next ##### grep 'github.com:ohnonot' */.git/config # all the git-internal ssh addresses that need to be changed sed 's#github.com:ohnonot#notabug.org:ohnonot#g' $(grep -lm1 'github.com:ohnonot' */.git/config) # simulated test run first sed -i 's#github.com:ohnonot#notabug.org:ohnonot#g' $(grep -lm1 'github.com:ohnonot' */.git/config) # do it! ##### now the monster loop ##### for i in * do if [ -d "$i" ] then if [ -d "$i/.git" ] then cd "$i" git status git add . git add * git commit -m 'github to notabug' git status git branch --set-upstream-to=origin/master master git pull git remote set-url --add --push origin git@framagit.org:ohnonot/$i.git git remote set-url --add --push origin git@notabug.org:ohnonot/$i.git git remote show origin git push cd /home/data/mygit read -p "##### Press Enter for next ##### " fi fi done

The monster loop works on the assumption that the folder name is the same as the repo name. It required manual intervention here and there, but was still much more convenient than doing it all manually.