Par Anonyme (non vérifié) , 29 avril 2026

Ce que vous accomplirez

Vous convertirez un dépôt SVN vers Git, en préservant auteurs, dates, branches et tags, et pousserez le résultat vers un host Git.

Étape 1 : préparer

svn info https://svn.example.com/repo
svn ls https://svn.example.com/repo

Étape 2 : construire le mapping des auteurs

svn log --xml https://svn.example.com/repo \
  | grep -E '<author>' \
  | sort -u \
  | sed -E 's/.*>(.+)<.*/\1 = \1 <\[email protected]>/' \
  > authors.txt
jdoe = Jane Doe <[email protected]>
bsmith = Bob Smith <[email protected]>

Étape 3 : convertir avec git svn

git svn clone \
    --stdlayout \
    --authors-file=authors.txt \
    https://svn.example.com/repo \
    repo.git
cd repo.git

Étape 4 : convertir les tags SVN en tags Git

git for-each-ref refs/remotes/origin/tags --format='%(refname:short)' \
  | while read ref; do
    tag="${ref#origin/tags/}"
    git tag "$tag" "$ref"
    git update-ref -d "refs/remotes/$ref"
  done

Étape 5 : convertir les branches SVN en branches Git

git for-each-ref refs/remotes/origin --format='%(refname:short)' \
  | grep -v '^origin/tags' \
  | while read ref; do
    branch="${ref#origin/}"
    if [ "$branch" != "trunk" ]; then
      git branch "$branch" "$ref"
    fi
    git update-ref -d "refs/remotes/$ref"
  done

Étape 6 : renommer trunk en main

git branch -m trunk main

Étape 7 : vérifier

git log --oneline | wc -l
svn log -q https://svn.example.com/repo | grep -c '^r'
git tag | wc -l
git branch | wc -l

Étape 8 : push vers un host Git

git remote add origin [email protected]:myorg/repo.git
git push -u origin --all
git push origin --tags

Étape 9 : gérer les externals

  • Vendor.
  • Submodules.
  • Gestionnaire de paquets.

Étape 10 : gérer le contenu volumineux ou binaire

git filter-repo --strip-blobs-bigger-than 50M
git lfs migrate import --include="*.psd,*.zip" --everything

Étape 11 : communiquer le cutover

Étape 12 : garder SVN en lecture seule

Pièges courants

  • Fichier d'auteurs incomplet.
  • Layout non standard.
  • Tracking de merge SVN.
  • Répertoires vides.