Da Anonimo (non verificato) , 29 Aprile 2026

Cosa otterrai

Convertirai un repository SVN in Git, preservando autori, date, branch e tag, e pusherai il risultato a un host Git.

Passo 1: preparare

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

Passo 2: costruire la mappatura autori

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]>

Passo 3: convertire con git svn

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

Passo 4: convertire tag SVN in tag 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

Passo 5: convertire branch SVN in branch 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

Passo 6: rinominare trunk in main

git branch -m trunk main

Passo 7: verificare

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

Passo 8: pushare a un host Git

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

Passo 9: gestire externals

  • Vendorizzare il codice esterno.
  • Submodule.
  • Package manager.

Passo 10: gestire contenuto grande o binario

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

Passo 11: comunicare il cutover

  • Annunciare la data di cutover.
  • Rendere SVN read-only.
  • Fornire istruzioni di clonazione.
  • Pianificare formazione.

Insidie comuni

  • File authors incompleto.
  • Layout non standard.
  • Tracking merge SVN.
  • Directory vuote.