Using git-svn (historical)
This guide is still incomplete.
Creating a git-svn repository
If you have commit access to the master SVN repository, you may wish to configure a git-svn repository that allows you to review and commit pull requests from contributors who do not have commit access. To make it easier for non-committers to interact with both Git and SVN, use the
svn://anonsvn.mit.edu/krb5 URL as the SVN root that git-svn writes into the commit objects.
If you do not have commit access, you will probably prefer to clone the public git-svn repository and ignore SVN.
Cloning the GitHub repository
To clone our GitHub repository and end up with a git-svn repository that you can use to commit to the master SVN repository: [XXXX needs testing]
git clone git://github.com/krb5/krb5-anonsvn krb5-github cd krb5-github git svn init -s --rewrite-root=svn://anonsvn.mit.edu/krb5 --prefix=origin/ svn+ssh://svn.mit.edu/krb5 git svn fetch git update-ref -d refs/remotes/origin/HEAD git update-ref -d refs/remotes/origin/master git checkout -b trunk origin/trunk git branch -d master
Be aware that the
git svn fetch command (which builds your local copy of the git-svn metadata) could take about two hours to run. The
git update-ref commands are to delete some spurious branches that are caused by the existence of a SVN branch named "HEAD" (don't ask) in our SVN repository.
The git-svn repository created using the above commands may be updated using either
git svn fetch (updates from the master SVN repository) or
git fetch (updates from GitHub).
Alternatively, you might use the following
git svn init command instead of the one above:
git svn init -s --commit-url=svn+ssh://svn.mit.edu/krb5 --prefix=origin/ svn://anonsvn.mit.edu/krb5
Importing directly from SVN (not recommended)
To set up a git-svn repository that fetches the entire commit history from the master SVN repository:
git svn clone -s --rewrite-root=svn://anonsvn.mit.edu/krb5 svn+ssh://svn.mit.edu/krb5 krb5-gitsvn
This has the advantage of fetching the commits from SVN using a secure transport.
On Git 188.8.131.52 on Ubuntu Lucid, the rewrite-root causes the fetch to stop at r17632, which contains a SVK merge ticket for the merge of the trunk into
Fetching all those revisions from
svn.mit.edu will take a really long time (possibly over 12 hours), so you may prefer alternatives that begin with cloning our existing public git-svn mirror. If you have an existing git-svn repository whose SVN root is the master SVN repository, you could use
git filter-branch to rewrite the URLs, or start over by cloning the published git-svn mirror.
Merge ticket incompatibility
The git-svn mirror of our master SVN repository has some quirks that result from changes in git-svn behavior over various Git releases. If you run into problems as a result, it's probably easiest to start over by cloning from our public git-svn mirror.
Since release 1.6.6 of Git,
git-svn can read merge tickets generated by SVK and SVN, and uses these merge tickets to create merge commits in Git. Some developers created git-svn repositories prior to this change in the behavior of git-svn, and these repositories have incompatible commit histories for otherwise identical tree histories. The commit that is most problematic in this way is r18200, which contains a SVK merge ticket for the merge of
branches/ccapi into the trunk. The git-svn mirror that we host on
krbdev.mit.edu and GitHub does not contain any merges that would be created by Git releases after 1.6.6.
If you have an existing git-svn repository that you would like to make compatible with the published git-svn mirror, you will probably need to use
git filter-branch with some graft points that delete the extra parent commits of the merge commits. You will need to rerun
git svn fetch afterward (which should operate locally without contacting the SVN repository if nothing has changed in SVN) to rebuild the git-svn metadata.
git filter-branch (not recommended)
git filter-branch command is very powerful and easy to misuse. Reasons why you might want to use it include modifying your existing git-svn repository to match the commit history of our public git-svn repository. You will probably prefer to recreate your patches on top of a fresh clone from our git-svn repository, unless you have a particularly complicated local revision history you want to preserve. Instructions on how to use
git filter-branch for this and related operations may appear here later if there is enough demand.
Keep the trunk branch free of local commits. Make each change on a separate branch off of the trunk (
git checkout -b branchname). When you have committed your work (with
git add and
git commit) and are ready to push changes to Subversion, first update your trunk branch and rebase with any local commits:
git checkout trunk git pull git checkout branchname git rebase trunk
Then (ideally after re-testing your changes) run
git svn dcommit to push your changes to Subversion from your branch. After a few minutes, these will propagate from Subversion to GitHub, and you can update your trunk branch to reflect them.