Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

[migration script] GitHub projects to GitLab #44

Closed
wants to merge 1 commit into from

5 participants

Ivan Lisenkov Valeriy Sizov Achilleas Pipinellis Malte N Adonis K.
Ivan Lisenkov

Please see my script, for automatically mirroring all user's github repos to gitlab instance

Ivan Lisenkov

Nobody interested?

Valeriy Sizov
Collaborator

sorry ;) This is good feature. Many people have asked for this. Gitlab team will check your request as soon as possible ;)

Achilleas Pipinellis
Collaborator

@ivlis Since now gitlab supports namespaces, could you modify your script? It is good for merge.

Achilleas Pipinellis
Collaborator

s/for/with

Achilleas Pipinellis
Collaborator

s/ssh-agen/ssh-agent

Achilleas Pipinellis axilleas referenced this pull request
Merged

[WIP] New repository structure #111

12 of 14 tasks complete
Achilleas Pipinellis axilleas was assigned
Adonis K.

This would be really great to have

Achilleas Pipinellis
Collaborator

Closed in favor of #156

Achilleas Pipinellis axilleas closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 21, 2013
  1. Add github to gitlab migration script

    Ivan Lisenkov authored
This page is out of date. Refresh to see the latest.
Showing with 53 additions and 0 deletions.
  1. +14 −0 github/README.md
  2. +39 −0 github/migrate.sh
14 github/README.md
View
@@ -0,0 +1,14 @@
+Migrate your repositories from github to gitlab
+=======================================
+
+
+1. Edit migrate.sh for your credentials
+2. Add your ssh key to ssh-agen if you have an encrypted key
+3. run ./migrate.sh
+
+If you want to migrate only private repos from github add
+"type=private" to github url.
+
+Unfortunaty, gitlab API doens't support namespaces yet, so all
+created repositories are prefixed for security
+
39 github/migrate.sh
View
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+GITHUB_USER=user # Your username on github
+GITHUB_PASSWORD='' # Your password on github
+
+GITLAB_PREFIX=from-github # All repos created on gitlab will be prefixed
+GITLAB_USER=user # Your username on your gitlab instance
+GITLAB_HOST=git.example.com # Your gitlab host WITHOUT SCHEMA
+GITLAB_TOKEN= # Your gitlab token
+
+TMP=`mktemp -dp .`
+cd $TMP
+
+
+curl -s -u "$GITHUB_USER:$GITHUB_PASSWORD" -i 'https://api.github.com/user/repos' |\
+ grep ssh_url > private_repos.txt
+
+while read line
+do
+ url=`echo $line | sed -r 's|^\s*"(.*)":\s"(.*)",*$|\2|'`
+ repo=`echo $url | sed -r 's|^.*/(.*)$|\1|'`
+ repo_name=`echo $repo | sed -r 's|^(.*).git$|\1|'`
+ curl -s -X POST -H "private-token: $GITLAB_TOKEN" \
+ -d " {\"name\" : \"$GITLAB_PREFIX-$repo_name\" } "\
+ "https://$GITLAB_HOST/api/v3/projects"
+ echo $url
+ git clone --bare $url $repo
+ cd $repo
+ push_url="git@$GITLAB_HOST:$GITLAB_USER/$GITLAB_PREFIX-$repo"
+ echo "Pushing to URL: $push_url"
+ git push --mirror $push_url
+ cd ..
+done < private_repos.txt
+
+cd ..
+
+rm -rf $TMP
+
+
Something went wrong with that request. Please try again.