Was Sie erreichen werden
Sie werden ein SVN-Repository zu Git konvertieren, Autoren, Daten, Branches und Tags bewahren und das Ergebnis zu einem Git-Host pushen.
Schritt 1: vorbereiten
svn info https://svn.example.com/repo
svn ls https://svn.example.com/repo
Schritt 2: Autoren-Mapping erstellen
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]>
Schritt 3: mit git svn konvertieren
git svn clone \
--stdlayout \
--authors-file=authors.txt \
https://svn.example.com/repo \
repo.git
cd repo.git
Schritt 4: SVN-Tags zu Git-Tags konvertieren
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
Schritt 5: SVN-Branches zu Git-Branches konvertieren
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
Schritt 6: trunk zu main umbenennen
git branch -m trunk main
Schritt 7: verifizieren
git log --oneline | wc -l
svn log -q https://svn.example.com/repo | grep -c '^r'
git tag | wc -l
git branch | wc -l
Schritt 8: zu einem Git-Host pushen
git remote add origin [email protected]:myorg/repo.git
git push -u origin --all
git push origin --tags
Schritt 9: Externals handhaben
- Externen Code vendoren.
- Submodule.
- Package Manager.
Schritt 10: grosse oder binare Inhalte handhaben
git filter-repo --strip-blobs-bigger-than 50M
git lfs migrate import --include="*.psd,*.zip" --everything
Schritt 11: den Cutover kommunizieren
- Cutover-Datum ankundigen.
- SVN read-only machen.
- Klon-Anweisungen geben.
- Training planen.
Haufige Fallstricke
- Unvollstandige Authors-Datei.
- Nicht-Standard-Layout.
- SVN-Merge-Tracking.
- Leere Verzeichnisse.