User:Dantman/Migrating from SVN to Git

Some drafts for changes to Migrating from SVN to Git.

Safely migrating your release checkout (branches/REL#_## or tags/REL#_##_*)
Make a backup of your files (doing your database aswell wouldn't be a bad thing)!

Before starting with your conversion you should run  and review how your wiki's checkout differs from the codebase.

You can ignore all the lines starting with a ?, especially the ones about things like extensions/, .htaccess files, and sitemaps. However if you see any M (modified) lines you will probably want to run  and review your modifications. If you have any modifications you will likely later either be dropping them or making them part of your git repo.

At this point we want to make sure that we are at a common point between svn and git that we can safely leap between expecting the whole file tree to be exactly the same. Check your ; If you are on tags/ you are in a good state. However for the many of us who have checkout out branches/ it's time to switch to a tag. branches are variable, and it is liable that the git branch we check out will have a different file tree which will cause migration issues.

If you're on a branches/ checkout follow these steps to switch to a tag:
 * 1) Take a look at your wiki's Special:Version and check precisely which version you have checked out.
 * 2) Look through http://svn.wikimedia.org/svnroot/mediawiki/tags/ and find a REL tag that matches your version. (note that you will be switching to the phase3/ inside of that) eg: If you're on 1.18.0 you'll want to check out tags/REL1_18_0/phase
 * 3) Run a   to the phase3 that tag. eg: If you're using anonymous http checkout an running 1.18.0 you'll use.
 * 4) If all things went well theoretically svn won't even bother having to modify any files. Whatever the case as long as you used the right tag things should turn out fine.

Now that you're on a tag we can start migration to git.


 * 1) Turn your wiki into a blank git repository using
 * 2) To avoid .svn cluttering your git status add .svn to your repo's private ignore/exclude list using
 * 3) Add mediawiki/core.git as a the remote 'origin' for your repository: (use -f --tags to have git fetch the commits and tags)
 * 4) * Anonymously:
 * 5) * Labs account (only if you plan to commit and have ssh ready):
 * 6) Wait for git to download all the commits. This will take a few minutes but you will only need to wait for this once.
 * 7) Do a soft reset to the tag that matches your svn tag:
 * 8) * Our git tags use the normal '.' format, so for tags/REL1_18_0 you'll want the tag '1.18.0'
 * 9) * Soft reset to that tag:
 * 10) * eg: For tags/REL1_18_0/phase3 you would use

At this point we have a repository with a working tree tied to a specific release but with a working copy that contains any modifications left over. At this point our working tree undoubtedly contains modifications from the git version we are paired with. At the very minimum there are many $Id$ changes from your svn checkout inside includes/api/ which you need to have dropped.
 * 1) Clear the svn '$Id: ...$'s from MW using the following command:
 * 2) You will have some leftover modifications to clear out:
 * 3) * Run  you will be asked what modifications you wish to discard:
 * 4) ** If you see a diff comparing something like  and   use "y" to discard it (if you're asked "Apply them to the worktree anyway?" use another "y")
 * 5) ** Same if you are sure you do not want the modification anymore.
 * 6) ** If it's a modification you wish to keep answer "n".
 * 1) ** If it's a modification you wish to keep answer "n".