Migrating a project from SVN to Git

To migrate a project you need to have superuser access to srv04.typo3.org, if you lack that you can stop reading now. :)

Migrating a project goes like this:

Hard part

root@srv04:~/git-helpers# ./migrate.sh 

Usage: ./migrate.sh <svn-path> <forge-id>
  e.g. ./migrate.sh FLOW3/Packages/FLOW3 package-flow3

root@srv04:~/git-helpers# ./migrate.sh FLOW3/Packages/SwiftMailer package-swiftmailer
Initialized empty Git repository in /root/git-helpers/tmp/SwiftMailer/.git/
Using higher level of URL: https://svn.typo3.org/FLOW3/Packages/SwiftMailer => https://svn.typo3.org/FLOW3
W: Ignoring error from SVN, path probably does not exist: (160013): Filesystem has no item: File not found: revision 100, path '/Packages/SwiftMailer'
W: Do not be alarmed at the above message git-svn is just searching aggressively for old history.
This may take a while on large repositories
r3997 = a135410ee7a898535cb8ef1f2050019200aec2ed (trunk)
    A    Meta/Package.xml
    A    Resources/Private/PHP/SwiftMailer/mime_types.php
    A    Resources/Private/PHP/SwiftMailer/swift_required.php
    A    Resources/Private/PHP/SwiftMailer/swift_init.php
    A    Resources/Private/PHP/SwiftMailer/preferences.php
    A    Resources/Private/PHP/SwiftMailer/swift_required_pear.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/ByteStream/AbstractFilterableInputStream.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/ByteStream/ArrayByteStream.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/ByteStream/FileByteStream.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/EmbeddedFile.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Encoder/QpEncoder.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Encoder/Rfc2231Encoder.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Encoder/Base64Encoder.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Plugins/BandwidthMonitorPlugin.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Plugins/Decorator/Replacements.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Plugins/Loggers/ArrayLogger.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Plugins/Loggers/EchoLogger.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Plugins/AntiFloodPlugin.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Plugins/LoggerPlugin.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Plugins/Logger.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Plugins/Reporters/HitReporter.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Plugins/Reporters/HtmlReporter.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Plugins/Sleeper.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Plugins/Timer.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Plugins/DecoratorPlugin.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Plugins/ReporterPlugin.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Plugins/Reporter.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Plugins/PopBeforeSmtpPlugin.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Plugins/ThrottlerPlugin.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Plugins/Pop/Pop3Exception.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Plugins/Pop/Pop3Connection.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Transport.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/DependencyException.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/ReplacementFilterFactory.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/OutputByteStream.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/SmtpTransport.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Mime/EmbeddedFile.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Mime/SimpleHeaderFactory.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Mime/SimpleMimeEntity.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Mime/SimpleMessage.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Mime/EncodingObserver.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Mime/CharsetObserver.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Mime/HeaderEncoder/QpHeaderEncoder.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Mime/HeaderEncoder/Base64HeaderEncoder.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Mime/HeaderSet.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Mime/ParameterizedHeader.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Mime/ContentEncoder.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Mime/SimpleHeaderSet.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Mime/MimePart.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Mime/HeaderFactory.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Mime/ContentEncoder/QpContentEncoder.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Mime/ContentEncoder/PlainContentEncoder.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Mime/ContentEncoder/Base64ContentEncoder.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Mime/Message.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Mime/MimeEntity.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Mime/Headers/AbstractHeader.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Mime/Headers/UnstructuredHeader.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Mime/Headers/IdentificationHeader.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Mime/Headers/MailboxHeader.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Mime/Headers/ParameterizedHeader.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Mime/Headers/PathHeader.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Mime/Headers/DateHeader.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Mime/HeaderEncoder.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Mime/Header.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Mime/Attachment.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Preferences.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/LoadBalancedTransport.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Transport/SendmailTransport.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Transport/SimpleMailInvoker.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Transport/MailTransport.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Transport/MailInvoker.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Transport/IoBuffer.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Transport/Esmtp/Authenticator.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Transport/Esmtp/Auth/PlainAuthenticator.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Transport/Esmtp/Auth/CramMd5Authenticator.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Transport/Esmtp/Auth/LoginAuthenticator.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Transport/Esmtp/AuthHandler.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Transport/SmtpAgent.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Transport/AbstractSmtpTransport.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Transport/FailoverTransport.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Transport/EsmtpTransport.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Transport/StreamBuffer.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Transport/EsmtpHandler.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Transport/LoadBalancedTransport.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/CharacterReaderFactory.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/TransportException.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/KeyCache.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/MimePart.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/CharacterReader.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/DependencyContainer.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/CharacterReaderFactory/SimpleCharacterReaderFactory.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Image.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/FailoverTransport.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Message.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Encoding.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/KeyCache/ArrayKeyCache.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/KeyCache/SimpleKeyCacheInputStream.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/KeyCache/DiskKeyCache.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/KeyCache/NullKeyCache.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/KeyCache/KeyCacheInputStream.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Attachment.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/CharacterReader/Utf8Reader.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/CharacterReader/GenericFixedWidthReader.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/CharacterReader/UsAsciiReader.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/FileStream.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/StreamFilters/StringReplacementFilter.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/StreamFilters/StringReplacementFilterFactory.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/StreamFilters/ByteArrayReplacementFilter.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/InputByteStream.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/MailTransport.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/StreamFilter.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/CharacterStream.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Mailer.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Filterable.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/SendmailTransport.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/SwiftException.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Events/SendEvent.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Events/TransportExceptionEvent.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Events/SendListener.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Events/CommandEvent.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Events/ResponseEvent.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Events/Event.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Events/TransportExceptionListener.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Events/SimpleEventDispatcher.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Events/CommandListener.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Events/ResponseListener.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Events/TransportChangeEvent.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Events/EventListener.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Events/EventDispatcher.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Events/EventObject.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Events/TransportChangeListener.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Encoder.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/CharacterStream/NgCharacterStream.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/CharacterStream/ArrayCharacterStream.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Mailer/ArrayRecipientIterator.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/Mailer/RecipientIterator.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/RfcComplianceException.php
    A    Resources/Private/PHP/SwiftMailer/classes/Swift/IoException.php
    A    Resources/Private/PHP/SwiftMailer/dependency_maps/cache_deps.php
    A    Resources/Private/PHP/SwiftMailer/dependency_maps/mime_deps.php
    A    Resources/Private/PHP/SwiftMailer/dependency_maps/transport_deps.php
r4001 = 233ec3fc1c78843b84790e660b6dc54b10cf648b (trunk)
    A    Configuration/Settings.yaml
    A    Configuration/Objects.yaml
    A    Classes/Mailer.php
    A    Classes/TransportInterface.php
    A    Classes/Exception.php
    A    Classes/Message.php
    A    Classes/TransportFactory.php
r4007 = a4c012a44274dd939410e55516f1a168e1d80540 (trunk)
    M    Configuration/Objects.yaml
    M    Classes/Mailer.php
    A    Classes/MailerInterface.php
    M    Classes/TransportInterface.php
    M    Classes/Exception.php
    M    Classes/Message.php
    M    Classes/TransportFactory.php
r5013 = e83e88dc6bd764b3425491d9bf0ee681918d0de5 (trunk)
Checked out HEAD:
  https://svn.typo3.org/FLOW3/Packages/SwiftMailer/trunk r5013
cp: cannot stat `.git/refs/remotes/tags/*': No such file or directory
Deleted branch trunk.
Initialized empty Git repository in /var/gerrit/review/git/FLOW3/Packages/SwiftMailer.git/
remote: Counting objects: 197, done.
remote: Compressing objects: 100% (191/191), done.
Receiving objects: 100% (197/197), 117.50 KiB, done.
Resolving deltas: 100% (72/72), done.
remote: Total 197 (delta 72), reused 0 (delta 0)
Did the migration work? If not, press Ctrl-C, any key to continue...
Initialized empty Git repository in /var/git/repositories/FLOW3/Packages/SwiftMailer.git/
/root/git-helpers/tmp
Did the local init work? If not, press Ctrl-C, any key to continue...
Initialized empty Git repository in /var/git/repositories/FLOW3/Packages/SwiftMailer.git/
Did the remote init work? If not, press Ctrl-C, any key to continue...
Setting up project in gerrit...
Restarting gerrit...
Stopping Gerrit Code Review: OK
Starting Gerrit Code Review: OK
root@srv04:~/git-helpers# 

So, if we strip the output (booooring, right?) it boils down to this:

root@srv04:~/git-helpers# ./migrate.sh FLOW3/Packages/SwiftMailer package-swiftmailer

The forge project id is used to sync project membership between redmine and gerrit.

Cleanup and check

Afterwards check the project in gerrit to see if everything is set up as desired (CLA enforcement, permissions).

Gerrit will populate the project group with members by syncing with Forge regularly, so you simply need to wait for this to happen.

In the project settings on Forge you can now switch the repository from Subversion to Git, the path needed is

/var/git/repositories/<projectname>.git

It might be wise to empty SVN trunk in the migrated project when done, so that users do not get confused. You can also place a file there explaining the migration.