We already have a git repo, but we want to interact with a system that currently works using svn. The svn repo is mainly for read-only but the setup should not block any potential direct writes to the svn.
git-svn is great, but the default setup is for when svn is the master and git is the personal client.
Also we do not want to clobber the history.
In the following alis is the name for both the name that I choose to assign to the remote, and to the git-svn identifier for the remote.
I dont know why they are not always set to be the same.
git svn clone -ialis -Ralis svnUrl repoName cd repoName mv .git/refs/heads/master ./git/refs/heads/svn git checkout svn
At this stage your
.git/config should look something like this:
[core] repositoryformatversion = 0 filemode = true bare = false logallrefupdates = true [svn-remote "alis] url = svnUrl fetch = :refs/remotes/alis
Edit it to look something like this:
[core] repositoryformatversion = 0 filemode = true bare = false logallrefupdates = true [remote "origin"] fetch = +refs/heads/*:refs/remotes/origin/* url = originUrl [svn-remote "alis"] url = https://alis.cs.bath.ac.uk/svn/cs3mmh fetch = :refs/remotes/alis [branch "svn"] remote = alis merge = : [branch "master"] remote = origin merge = refs/heads/master
git fetch origin git checkout master
At this stage everything from origin is in master, and the things in svn lives in the svn branch.
If we dont care about the history, we can simply merge master into svn and we will be done.
if we need to preserve history we have to do:
# work in temp branch so that we dont accidentilly screw things up. git branch temp --track master git checkout temp git rebase --onto svn --root temp # May have some conflicts resolve and continue. # Inspect history and files when rebase is finnished. # Assuming everything went well git checkout svn # bring in the changes from temp, but only fast forward git merge --ff temp # push everything onto svn server git svn dcommit git branch -d temp
continue working on master and when wanting to update the svn system do the last few steps. If the svn has been updated, just cherry-pick the change from the svn branch onto master.