SVN to GitLab Migration: Best Practices for History, Groups and CI/CD
Converting the history is the small part. The order that works is inventory, a scripted git-svn conversion, a group tree per product, shared pipeline components, one pilot, then a cutover per team.
Key takeaways
- Migrate SVN to GitLab by converting each product with git-svn and a complete authors file, turning SVN tags into real Git tags, then pushing into one GitLab subgroup per product.
- Build shared CI/CD components and group runners before the first team moves.
- Pilot one product, set SVN read-only at cutover and repeat.
On this page
Treat an SVN to GitLab migration as two projects. The first converts history with git-svn and is finished in days. The second builds the groups, branching rules and shared pipelines every team will inherit, and it decides whether the move was worth making. Do the second one before the first team cuts over.
Verified againstChecked against official docs
git-svn manual from Git 2.54, the Pro Git "Migrating to Git" chapter, the git-lfs-migrate manual and the GitLab docs with 19.7 as the newest listed release. Commands were checked against those pages, not run against a live SVN server. Checked November 2026.
A typical case: several products on one Subversion server, a decade of history, and a plan to land in GitLab with builds, tests, scans and deployments that look the same in every project. The sections below follow the order that keeps that plan from stalling.
Inventory before you convert anything
Subversion lets a repository grow shapes that Git has no equivalent for. Find them first, because each one changes the conversion command.
- Layout. Does each project use the standard
trunk/,branches/,tags/directories, or did someone put branches underreleases/anddev/? Is it one SVN repository per product, or one repository with twenty product folders? - Externals.
svn:externalspulls other paths into a working copy. The git-svn manual states that it ignores every SVN property exceptsvn:executable, so externals vanish unless you replace them. - Binaries. SVN users commit installers, database dumps and vendor JARs because a checkout only fetches one revision. A Git clone fetches all of them.
- Dead code. Projects nobody has built in five years do not need a pipeline. Archive them as read-only Git repositories or leave them in the SVN backup.
- People. Every SVN username that ever committed needs a name and email in Git.
The inventory produces one spreadsheet row per future GitLab project: SVN path, layout flags, externals, binary size, owning team, migrate or archive. That sheet is the migration plan.
Convert history with git-svn, and fix the authors file first
git-svn ships with Git and reads the SVN server directly. Start with the author mapping. The Pro Git book gives the extraction pipeline:
svn log --xml --quiet | grep author | sort -u | \
perl -pe 's/.*>(.*?)<.*/$1 = /'
Save the output as authors.txt and complete each line in the form jsmith = Jane Smith <jane.smith@example.com>. Use the email address each person will have in GitLab so commits link to their account. The file must be complete: per the manual, when git-svn meets a committer that is not in the file, it aborts. For departed staff and service accounts, map to a real name with an empty <> email or a placeholder address.
Then clone. For a standard layout:
git svn clone https://svn.example.com/repos/billing \
--stdlayout --authors-file=authors.txt --preserve-empty-dirs billing
cd billing
--stdlayout (short form -s) tells git-svn that trunk, branches and tags sit at the default paths. For anything else, pass --trunk, --branches and --tags explicitly; --branches and --tags can each be given more than once. When one SVN repository holds many products, point the URL at the product folder so each product becomes its own Git repository.
Three details save a rerun:
Keep the metadata. Pro Git's example adds --no-metadata to strip the git-svn-id: line from every commit message. The git-svn manual says that option "can only be used for one-shot imports as git svn will not be able to fetch again without metadata." You want to fetch again at cutover, and those lines let anyone map an old ticket's "r4812" to a Git commit. Leave it off.
Tags arrive as branches. Because SVN allows commits to a tag, git-svn "imports all SVN tags as branches, prefixing the tag name with tags/". With the default origin/ prefix they sit under refs/remotes/origin/tags/. Convert them, and turn the remaining remote refs into local branches:
git for-each-ref --format='%(refname:short)' refs/remotes/origin/tags |
while read ref; do git tag "${ref#origin/tags/}" "$ref"; done
git for-each-ref --format='%(refname:short)' refs/remotes/origin |
grep -v -e '^origin/tags/' -e '^origin/trunk$' -e '@' |
while read ref; do git branch "${ref#origin/}" "$ref"; done
git branch -M main
The grep drops the tags you already converted, trunk (your checked-out branch already tracks it) and the name@1234 peg-revision refs git-svn creates when a branch was deleted and recreated. Delete stale branches now; nobody will do it later.
Ignores and externals need a manual step. git svn create-ignore writes .gitignore files that match the svn:ignore properties and stages them for you to commit. git svn show-externals lists the externals. Replace each one with a package from your artifact registry where the dependency is a versioned library, or a Git submodule where it really is shared source.
Before pushing, deal with binaries. git lfs migrate info --everything summarizes file types by size across all history, and git lfs migrate import --everything --include="*.zip,*.jar" rewrites those types into Git LFS pointers. The import rewrites commits, so run it before the first push, never after people have cloned. If an oversized file slips through anyway, the cleanup is the one in our guide to removing a large file from Git history.
Then push to an empty GitLab project:
git remote add origin git@gitlab.example.com:acme/billing/billing-api.git
git push origin --all
git push origin --tags
Put every command above in one script that takes an SVN path and a GitLab project path. You will run it many times: a rehearsal, a fix, another rehearsal, then the real cutover. Keep the git-svn clone itself untouched and run the tag, branch and LFS steps on a copy of the directory, so the original can still fetch new revisions cleanly.
Where this breaks: git-svn replays every revision over the network, so very large repositories take hours or days on the first clone. Run it on a machine next to the SVN server and keep the result, because git svn fetch afterwards only pulls new revisions. Do not expect SVN merge tracking to turn into a clean Git merge graph either: check a few merges you know about in the converted history before anyone relies on git log --merges.
Split by product, not by SVN server
The SVN server's shape is an accident of who set it up. The Git layout should follow ownership and release cadence: code that is built, versioned and deployed together belongs in one project. A product folder with its own trunk becomes its own GitLab project. A shared library used by four products becomes its own project that publishes a package.
Keep a monorepo only where teams already change the pieces together in single commits and will keep doing so. Splitting later is possible but rewrites history; merging later is easy. When in doubt, split along the lines where different teams hold commit rights today.
One top-level group, one subgroup per product
GitLab permissions flow downward. When you add a member to a group, that member is also added to every subgroup and project beneath it, so the group tree is the access model. GitLab allows subgroups nested up to 20 levels and recommends five or fewer. Three is enough for most organizations:
| Level | Example | What lives here | Who owns it |
|---|---|---|---|
| Top-level group | acme | SSO, group runners, group CI/CD variables, protected environment rules | Platform team |
| Platform subgroup | acme/platform | CI/CD components, base images, deploy tooling | Platform team |
| Product subgroup | acme/billing | The product's projects, product-level variables | Product team lead |
| Project | acme/billing/billing-api | Code, .gitlab-ci.yml, environments | Developers |
Grant roles at the product subgroup, not per project. The role list as of GitLab 19.7 is Minimal Access, Guest, Planner, Reporter, Security Manager, Developer, Maintainer and Owner. Developers write code and open merge requests; a small number of Maintainers per product merge to protected branches and manage settings; Owner stays with the platform team and one named lead.
GitLab protects the default branch by default, with Maintainers allowed to push and merge. Keep that, and add branch protection for release branches. Two controls most organizations ask for are paid: Code Owners approval and push rules (branch name patterns, signed commits) are Premium and Ultimate features.
Pick a branching model SVN users can follow
Teams coming from SVN know trunk and they know release branches. Give them the same thing in Git. GitLab's own branching guidance says: "Don't implement a strategy that is more complex than your product needs," and describes the simple default of working in a feature branch and merging it directly to main.
A request for "development, feature, release, hotfix and production branches" maps onto that like this:
- Development is
main. It is protected, always buildable, and every change arrives by merge request. - Feature branches are short-lived, named
feature/<ticket>-<slug>, and deleted on merge. Days, not months. - Release branches (
release/2.4) exist only for products that support several shipped versions at once. A web service deployed frommaindoes not need them. - Hotfix is a feature branch cut from the release branch, or from
mainwhen there are no release branches, with the fix then carried to the other one. - Production is not a branch. It is a Git tag plus a GitLab environment. A long-lived
productionbranch only adds a place for history to diverge.
Full GitFlow, with its permanent develop branch, doubles the merges people fresh from SVN have to reason about. Decide the merge method once per group as well; the tradeoffs are in our comparison of rebase and merge.
One components project, thin project pipelines
The mistake that hurts a year in is letting every team write its own .gitlab-ci.yml from scratch. Thirty pipelines drift, and adding a scanner means thirty merge requests. Put pipeline logic in one project and let products consume versioned pieces.
GitLab's mechanism for this is the CI/CD component, available on every tier: a reusable pipeline unit that lives in a templates/ directory, declares typed inputs and is included by version.
spec:
inputs:
stage:
default: build
image:
default: maven:3.9-eclipse-temurin-21
build-maven:
stage: $[[ inputs.stage ]]
image: $[[ inputs.image ]]
script:
- mvn -B verify
artifacts:
reports:
junit: target/surefire-reports/TEST-*.xml
A product's pipeline is then a short list of includes:
include:
- component: $CI_SERVER_FQDN/acme/platform/ci-components/build-maven@1.4.0
- component: $CI_SERVER_FQDN/acme/platform/ci-components/deploy@1.4.0
inputs:
app_name: billing-api
- template: Jobs/SAST.gitlab-ci.yml
- template: Jobs/Secret-Detection.gitlab-ci.yml
Write one build component per technology stack (Maven, .NET, Node, whatever the inventory found) and stack-independent components for API tests, UI automation, performance tests and deployment. Each stack differs in the build step; the stages and the deployment contract stay identical everywhere.
Pin versions. GitLab resolves a component reference by commit SHA, tag or branch, and warns that ~latest can include breaking changes. Projects pin a release tag and upgrade on purpose, through a merge request. Projects can still override an included job's keys, with one catch from the include docs: arrays such as script are replaced whole, not merged. This is the same design as reusable workflows on GitHub Actions, and if the organization is still choosing a CI system, the cost side is in GitLab CI vs Jenkins.
One tier note: enforcing a job so a project cannot remove it takes a pipeline execution policy, which is Ultimate. On Free and Premium, the control is review. Make the platform team a required reviewer for changes to .gitlab-ci.yml.
Environments, approvals and rollback are settings, not scripts
Model Dev, QA, UAT and Production as GitLab environments and set the tier explicitly so group-level rules can match on it:
# templates/deploy.yml (excerpt)
deploy-production:
stage: deploy
script:
- ./deploy.sh "$CI_COMMIT_TAG"
environment:
name: production
url: https://billing.example.com
deployment_tier: production
rules:
- if: $CI_COMMIT_TAG
Environments and manual rollback work on every tier. In the environment's deployment list, Rollback environment next to an earlier successful deployment re-runs that deployment job against the old commit. GitLab re-runs only the deployment job, so the rollback is as good as your deploy script: it must be able to ship any previous version from a stored artifact or image tag, without rebuilding.
Approval gates are paid. Protected environments (who may deploy) and deployment approvals (how many named approvers must sign off) are Premium and Ultimate. A group can protect by deployment tier, so one rule at acme covers every project's production environment and subgroups cannot override it. On the Free tier, the substitute is a manual job on a protected branch or tag, which limits who can press the button but records no approval.
Runners, secrets and scanning: what each tier gives you
Register runners at the group level so every project under acme gets them without setup; project runners are for the rare job with special hardware. Use the Docker or Kubernetes executor so every job starts in a clean container. The shell executor is in maintenance mode, and it lets one job's leftovers break the next. The buy-or-run math is in our piece on self-hosted runner costs.
For cloud credentials, skip stored keys. The id_tokens keyword issues a short-lived OIDC token per job on every tier, and the trust policy on the cloud side decides which project and branch may use it. The claims to pin are covered in GitLab OIDC to AWS. What must stay a CI/CD variable should be masked and protected so it is only exposed to protected branches and tags.
Budget for the tier you need before promising governance features. As of GitLab 19.7:
| Capability | Free | Premium | Ultimate |
|---|---|---|---|
CI/CD components, include, environments, manual rollback | Yes | Yes | Yes |
OIDC id_tokens, group runners | Yes | Yes | Yes |
| SAST, pipeline secret detection, container and IaC scanning | Job and JSON report | Job and JSON report | Plus merge request reports and vulnerability management |
| Code Owners, push rules | No | Yes | Yes |
| Protected environments, deployment approvals | No | Yes | Yes |
| Group and project audit events | No | Yes | Yes |
| Dependency scanning, DAST, secret push protection | No | No | Yes |
| Pipeline execution policies, DORA metrics | No | No | Yes |
A gap on Free or Premium is not a blocker. Open-source scanners run fine as jobs in your own components; our SCA, SAST and DAST program guide covers which ones and how to keep the findings actionable, and securing the pipeline itself covers the runner and token side.
For reporting, CI/CD analytics on every tier shows pipeline counts, median duration and success and failure rates per project. Deployment frequency and the other DORA metrics need Ultimate, or a small exporter that reads the deployments API.
Roll out one team at a time, with SVN read-only at cutover
A same-day switch for every product fails on the first surprise. Run a pilot: one product with an engaged team, taken from conversion to a production deploy through the shared components. Everything the pilot breaks gets fixed in the script and the components, not in the product.
Then repeat this cutover for each product:
- Rehearse a week ahead: full conversion into a scratch GitLab project, pipeline green, team clones and builds.
- Announce a freeze window. Developers commit or shelve open work in SVN.
- Set the SVN path read-only for everyone except the migration account.
- Run
git svn fetchin the kept conversion repository to pull the last revisions, copy it, run the ref and LFS steps on the copy, and push. - Compare: file tree of
mainagainst ansvn exportof trunk, plus branch and tag counts. - Team clones from GitLab. Build servers, IDE configs and documentation links are repointed.
- SVN stays read-only, never deleted, until the retention period your auditors require has passed.
Do not run SVN and Git as two writable systems. git svn dcommit can send Git commits back to SVN, but the manual says running git merge or git pull is "NOT recommended on a branch you plan to dcommit from", and a workflow with rules like that does not survive a whole team. One writable source of truth per product at any moment.
Two weeks of training matter more than any tooling here. SVN users expect a commit to be shared the moment it is made, expect revision numbers to count upward and have never resolved a rebase conflict. Teach the merge request workflow on the pilot repository and point people at a Git error reference for the first month.
Questions people ask
Can SVN and Git run in parallel during the migration?
Per product, no: one system should be writable at a time. Across the organization, yes, and that is the normal state for months. Products that have cut over live in GitLab while the rest stay in SVN. Before a product's cutover you can refresh its Git copy with git svn fetch as often as you like, as long as nobody pushes to it.
Should SVN tags become Git tags or branches?
Git tags. git-svn imports them as branches under tags/ because SVN permits commits to a tag, so convert each one with git tag and drop the branch. If the inventory finds tags that were committed to after creation, the converted tag points at the last of those commits, which is what a checkout of that SVN tag returned.
How do you migrate svn:externals to Git?
By hand, because git-svn ignores the property. List them with git svn show-externals. An external that points at a versioned library becomes a package dependency served from GitLab's package registry. An external that points at live shared source becomes a Git submodule pinned to a commit, or the code is moved into the consuming repository.
How long does an SVN to GitLab migration take?
The conversion of one repository takes hours to a few days of elapsed time, mostly the first git svn clone. The platform work (groups, components, runners, environments) is a few weeks for a small platform team. The rollout is paced by teams, not tools: plan one to two weeks per product, including the rehearsal and training.
The decision, concretely
- Standard layout, history matters?
git svn clone --stdlayout --authors-file, keep the metadata, convert tags, push. - History does not matter for an old project? Export trunk, commit it as one initial commit, and keep SVN read-only for archaeology. It is faster and nobody will miss revision 212.
- Multiple shipped versions in support?
mainplusrelease/x.ybranches. Otherwisemainand short-lived feature branches only. - Need approvals and audit trails on deployments? Budget for Premium before designing the workflow. On Free, protected tags and manual jobs are the ceiling.
- Thirty projects, five stacks? One components project with a build component per stack. Per-project pipelines stay under twenty lines.
The call we'd make
Convert with git-svn from a script, keep git-svn-id lines, and land each product in its own subgroup under one top-level group. Build the components project, group runners and environment rules before the pilot, use trunk-style branching with release branches only where versions demand them, and cut over one team at a time with SVN locked read-only. The caveat: if the organization needs enforced approvals or mandatory scans, settle the GitLab tier first, because those controls are what the paid tiers sell.
Sources
Cite this article
Kiril Urbonas (2026). SVN to GitLab Migration: Best Practices for History, Groups and CI/CD. DevOpsNess. https://www.devopsness.com/blog/svn-to-gitlab-migration-best-practices
[SVN to GitLab Migration: Best Practices for History, Groups and CI/CD](https://www.devopsness.com/blog/svn-to-gitlab-migration-best-practices) (Kiril Urbonas, DevOpsNess, 2026-11-29)
More from DevOps
Explore more articles in this category
Helm vs Kustomize: Which Kubernetes Config Tool to Use
Both manage Kubernetes manifests across environments, but they solve it in opposite ways. Templating versus patching, and when each one actually wins.
How to Fix OOMKilled (Exit Code 137) in Kubernetes
A pod dies, restarts, dies again, and the events say OOMKilled. Here is what exit code 137 actually means and how to stop the loop for good.
Artifact Promotion Instead of Rebuilds: The Release Control Pattern That Stopped Drift
A practical artifact promotion guide for CI/CD teams that were tired of hearing 'it passed in staging' after production behaved differently because the release was rebuilt.
You might have missed
Evergreen posts worth revisiting.