Import Repositories

The instructions below should help you when you need to import existing Git or Subversion repositories.

For both Git and Subversion import you first need to create a new, empty GitLab project to host the imported repository.

Git

The easiest way is to use Import project from directly when you creating a new project. Choose git Repo by URL to import from another repository available via HTTPS on gitlab.inf.ethz.ch.

To import at a later time or from a repository that is only available over ssh you can run the following commands:

git clone <user>@<repository_url> --mirror </some/local/directory>
cd </some/local/directory>
git remote add gitlab git@gitlab.inf.ethz.ch:<group>/<project>.git
git push --mirror gitlab

Subversion

This is the short version of the official guide working with our svn service.

First you need to extract the authors of all commits to a file authors.txt:

svn log https://svn.inf.ethz.ch/svn/<ou>/<repo> --xml | grep author | sort -u | perl -pe 's/.*>(.*?)<.*/$1 = $1 <$1>/' > ./authors.txt

Review this file and delete all lines not of the form login = login <login>. You can also complete the file with the full email addresses of all users.

Clone the repository with history assuming the standard layout and using the authors.txt file created before:

git svn clone https://svn.inf.ethz.ch/svn/<ou>/<repo> --stdlayout  --authors-file=./authors.txt --no-metadata

Now migrate tags and branches to the right places:

cd <repo>
cp -Rf .git/refs/remotes/origin/tags/* .git/refs/tags/
rm -Rf .git/refs/remotes/origin/tags
cp -Rf .git/refs/remotes/origin/* .git/refs/heads/ 
rm -Rf .git/refs/remotes
git branch -d trunk

Finally push the files to the repository:

git remote add origin git@gitlab.inf.ethz.ch:<group>/<repository>.git
git push origin --all
git push origin --tags

Are these instructions wrong, incomplete or outdated? Are they not helpful?
Please let us know.

Page URL: https://isg.inf.ethz.ch/bin/view/Main/HelpVersionControlGitLabImport
2019-11-18
© 2019 Eidgenössische Technische Hochschule Zürich