Git/Guide

Using the Mediawiki SVN Mirror on Github
There's an existing Mediawiki SVN Mirror hosted on Github. To get it do:

git clone git://github.com/mediawiki/mediawiki-svn.git

Using the Mediawiki SVN Mirror on Gitorious
There's another existing Mediawiki SVN Mirror hosted on Gitorious. To get it do:

git clone git://gitorious.org/mediawiki/mirror.git

Creating your own mirror
Clone MediaWiki's SVN repository into a new directory called "mediawiki". git svn clone --stdlayout http://svn.wikimedia.org/svnroot/mediawiki

If you have commit access, use this command instead. git svn clone --stdlayout svn+ssh://svn.wikimedia.org/svnroot/mediawiki

The resulting git repository contains the full history of trunk, branches, and tags to work on locally. However, the cloning process does take several days to complete.

Working with Git
The following documentation all assumes you're working with a remote Git repository created as discussed above.

Checking out new branches
By default you only track the  branch which corresponds to Subversion's. To check out and track another branch do:

git checkout -b REL1_15 --track origin/REL1_15

Rebuilding SVN metadata
TODO: If I get someone else's Git conversion how do I get it into a form like I'd  it? See this for an example that doesn't work. It gives:

$ git update-ref refs/remotes/trunk origin/svn/trunk fatal: origin/svn/trunk: not a valid SHA1

Commit / dcommit
First commit your changes locally as usual, e.g.,

git add foo.php includes/bar.php git commit

Then look them over and play with them if you like. When you're ready to commit them upstream, assuming you have commit access, you can run

git svn dcommit

This will check your commits against the origin, and commit any that you have and the origin doesn't. Of course, if you don't have commit access, you can still keep your local commits if you like, since git is a DVCS. will rebase them against any upstream changes, although needless to say, you have to manually fix any conflicts.

Links

 * Git and gerrit in Wikimedia sites
 * NOLA Hackathon/Sunday
 * File:Git notes - NOLA Hackathon 2011.pdf
 * File:Git notes - NOLA Hackathon 2011.oga
 * Git's website with documentation
 * An introduction to git-svn for Subversion/SVK users and deserter by Sam Vilain
 * A git branching model
 * git: the simple guide