debian-mirror-gitlab/doc/user/project/import/svn.md

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

92 lines
3.1 KiB
Markdown
Raw Normal View History

2020-06-23 00:09:42 +05:30
---
type: howto
stage: Manage
group: Import
2022-11-25 23:54:43 +05:30
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/product/ux/technical-writing/#assignments
2020-06-23 00:09:42 +05:30
---
2022-10-11 01:57:18 +05:30
# Migrate from Subversion to GitLab **(FREE)**
2018-03-17 18:26:18 +05:30
2022-10-11 01:57:18 +05:30
GitLab uses Git as its version control system. If you're using Subversion (SVN) as your version control system,
you can migrate to using a Git repository in GitLab using `svn2git`.
2018-03-17 18:26:18 +05:30
2022-10-11 01:57:18 +05:30
You can follow the steps on this page to migrate to Git if your SVN repository:
2018-03-17 18:26:18 +05:30
2022-10-11 01:57:18 +05:30
- Has a standard format (trunk, branches, and tags).
- Is not nested.
2018-03-17 18:26:18 +05:30
2022-10-11 01:57:18 +05:30
For a non-standard repository see the [`svn2git` documentation](https://github.com/nirvdrum/svn2git).
2018-03-17 18:26:18 +05:30
2022-10-11 01:57:18 +05:30
We recommend a hard cut over from SVN to Git and GitLab. Run the migration command once and then have all users use the
new GitLab repository immediately.
2018-03-17 18:26:18 +05:30
2022-10-11 01:57:18 +05:30
## Install `svn2git`
2018-03-17 18:26:18 +05:30
2022-10-11 01:57:18 +05:30
Install `svn2git` on a local workstation rather than the GitLab server:
2018-03-17 18:26:18 +05:30
2022-10-11 01:57:18 +05:30
- On all systems you can install as a Ruby gem if you already have Ruby and Git installed:
2018-03-17 18:26:18 +05:30
2022-10-11 01:57:18 +05:30
```shell
sudo gem install svn2git
```
2018-03-17 18:26:18 +05:30
2022-10-11 01:57:18 +05:30
- On Debian-based Linux distributions you can install the native packages:
2018-03-17 18:26:18 +05:30
2022-10-11 01:57:18 +05:30
```shell
sudo apt-get install git-core git-svn ruby
```
2018-03-17 18:26:18 +05:30
2022-10-11 01:57:18 +05:30
## Prepare an authors file (recommended)
2018-03-17 18:26:18 +05:30
2022-10-11 01:57:18 +05:30
Prepare an authors file so `svn2git` can map SVN authors to Git authors. If you choose not to create the authors file,
commits are not attributed to the correct GitLab user.
2018-03-17 18:26:18 +05:30
2022-10-11 01:57:18 +05:30
To map authors, you must map every author present on changes in the SVN repository. If you don't, the
migration fails and you have to update the author file accordingly.
2018-03-17 18:26:18 +05:30
2022-10-11 01:57:18 +05:30
1. Search through the SVN repository and output a list of authors:
2018-03-17 18:26:18 +05:30
2022-10-11 01:57:18 +05:30
```shell
svn log --quiet | grep -E "r[0-9]+ \| .+ \|" | cut -d'|' -f2 | sed 's/ //g' | sort | uniq
```
2018-03-17 18:26:18 +05:30
2022-10-11 01:57:18 +05:30
1. Use the output from the last command to construct the authors file. Create a file called `authors.txt` and add one
mapping per line. For example:
2018-03-17 18:26:18 +05:30
2022-10-11 01:57:18 +05:30
```plaintext
sidneyjones = Sidney Jones <sidneyjones@example.com>
```
2018-03-17 18:26:18 +05:30
2022-10-11 01:57:18 +05:30
## Migrate SVN repository to Git repository
2018-03-17 18:26:18 +05:30
2022-10-11 01:57:18 +05:30
`svn2git` supports excluding certain file paths, branches, tags, and more. See
the [`svn2git` documentation](https://github.com/nirvdrum/svn2git) or run `svn2git --help` for full documentation on all of
the available options.
2018-03-17 18:26:18 +05:30
2022-10-11 01:57:18 +05:30
For each repository to migrate:
2018-03-17 18:26:18 +05:30
2022-10-11 01:57:18 +05:30
1. Create a new directory and change into it.
1. For repositories that:
2018-03-17 18:26:18 +05:30
2022-10-11 01:57:18 +05:30
- Don't require a username and password, run:
2018-03-17 18:26:18 +05:30
2022-10-11 01:57:18 +05:30
```shell
svn2git https://svn.example.com/path/to/repo --authors /path/to/authors.txt
```
2018-03-17 18:26:18 +05:30
2022-10-11 01:57:18 +05:30
- Do require a username and password, run:
2018-03-17 18:26:18 +05:30
2022-10-11 01:57:18 +05:30
```shell
svn2git https://svn.example.com/path/to/repo --authors /path/to/authors.txt --username <username> --password <password>
```
2018-03-17 18:26:18 +05:30
2022-10-11 01:57:18 +05:30
1. Create a new GitLab project for your migrated code.
1. Copy the SSH or HTTP(S) repository URL from the GitLab project page.
1. Add the GitLab repository as a Git remote and push all the changes. This pushes all commits, branches, and tags.
2018-03-17 18:26:18 +05:30
2022-10-11 01:57:18 +05:30
```shell
git remote add origin git@gitlab.example.com:<group>/<project>.git
git push --all origin
git push --tags origin
```