Git-svn bare mirrors

I’ve been trying to automate the updating of my git-svn repos on my server via cron and I’ve finally succeeded in getting something working so I thought I’d share how I’ve got things setup since there seems to be a lack of information about how to do this.

First hurdle was git-svn doesn’t understand about bare repositories – it always looks for a .git directory. Fortunately this is easily solved since git-svn does support the $GIT_DIR environment variable. So I simply set this to . and run the git-svn commands from within the repository directory. So I initialise the repository with the appropriate git-svn init command and then call fetch to retrieve the svn history.

The next problem is that the refs fetched using git-svn are placed in refs/remotes which isn’t cloned when you do a regular git clone. So we need to plugin to the hooks to update the refs after we update the repository; an example script of how to this is provided below (Taken from dscho.git):

git for-each-ref –format=”%(refname)” refs/remotes |
sed “s/refs\/remotes\///” |
while read ref
git update-ref refs/heads/svn/$ref refs/remotes/$ref

git for-each-ref –format=”%(refname)” refs/heads/svn |
sed “s/refs\/heads\/svn\///” |
while read ref
if ! git-rev-parse refs/remotes/$ref > /dev/null 2>&1
git update-ref -d refs/heads/svn/$ref refs/heads/svn/$ref
I call the script from the post-update script (which you should make executable by running chmod +x hooks/post-update). This script suffices but doesn’t quite do what I’d like; I’d like the tags to be placed in refs/tags/svn rather than refs/heads/svn, but the script linked will do for me for now.
My cloned repositories are available at, unfortunately I can’t offer the git protocol since my host doesn’t allow it. As I get time I’ll convert more of the Gnome repositories; I’ve only converted the ones I know I’m going to be working on for the moment.

Tags: ,

36 Responses to “Git-svn bare mirrors”

  1. RubenV says:

    Hi James, thanks for blogging about this. By any chance, did you encounter repositories that use svn:externals?

  2. DaveV says:

    Just wanted to add my thanks to you for taking on this project. You probably already know this, but this idea has over 1700 votes for it on the Ubuntu Brainstorm website:

    Note that if one enables compiz and disables the nautilus desktop, this can be accomplished by compiz (I have been running like this for 6 months). I assume however, your solution will not require compiz.

    You may also want to check out this video as it is a decent proof-of-concept of this idea along with the idea of different icons per workspace.

    Do you plan to support different icons per workspace? In your previous blog you mentioned a directory for each workspace. Perhaps this is the way to accomplish this. Different icons in each workspace is a gnome bug that goes back to 2006.

    In any event, there are many thousands of us who look forward to your work! Thank you!

  3. James Sharpe says:

    Yes I have come across repositories with svn:externals. I’m currently ignoring these as jhbuild does the right thing when fetching from a git-svn conversion by parsing the unhandled.log created by git-svn. I don’t think that reconstructing the svn metadata recreates the unhandled.log file though, but I can’t really think of a nice solution to the problem of externals. Even submodules don’t really help as they require committing to the repository each update which breaks the ability to pull from the tracking repository.
    Any ideas are welcome!

  4. John Carr says:

    Hi James

    Thanks for blogging about this. I’m in the process of mirroring the whole of – you can see the progress at Its a bit slow right now with the gimp mirror taking an age to run. It may well be saturday before the initial run is complete and the box isn’t dog slow. Once its all converted and i’ve applied your suggestions i’m hoping to have it run along side (which is on the same box). With git-daemon, and hopefully some GNOME colouring.

    When I get this going, the mirror should never be more than 5 minutes out of date, as I use the svn-commits-list to pull/fetch a module as it changes. For bzr-mirror, it even automatically clones new modules when they are added. It seems this will be doable for git-mirror too.

  5. James Sharpe says:

    DaveV: yes I have seen that you can do this via compiz. When I mentioned a directory per workspace I was actually referring to gconf keys and not the actual Desktop directory. AFAIK the Desktop directory is one of those things standardised by and so its not a good idea to go changing the location of the desktop, and so no I’m not planning to implement different icons on each desktop.

  6. Steven Walter says:

    There’s a simpler solution than having a hook to update a ref. Instead, just make refs/heads/svn/foo a symbolic ref of refs/remotes/foo: git symbolic-ref refs/heads/svn/foo refs/remotes/foo

  7. James Sharpe says:

    Steven Walter: That’s what I originally did, but it doesn’t work when git packs the refs – they no longer track each other once they’ve been placed in packed-refs and I also want the refs to automatically track the branches in svn – if a branch is deleted or created I want that to automatically follow in the git repo.

  8. I’ve made a post-update script to handle both tags and branches here:

  9. Dacey says:

    thanks for the info on the scripts.

  10. Ella Walker says:

    I usually submit 300 word articles on article directories to help me gain backlinks and readers.;:`

  11. dalore says:

    How do you do a git-svn dcommit?

  12. Lost, Again…

    I do not have a clue about this topic. None of it does make sense to me….

  13. Hi there i am kavin, its my first time to commenting anyplace, when
    i read this paragraph i thought i could also make
    comment due to this brilliant post.

  14. After looking over a few of the blog posts on your website, I really like your technique of blogging.

    I saved it to my bookmark webpage list and
    will be checking back soon. Please visit my
    web site too and let me know how you feel.

  15. Wonderful article! This is the kind of info that
    should be shared across the web. Disgrace on Google for not positioning this put up higher!
    Come on over and visit my web site . Thanks =)

  16. My partner and I stumbled over here different website and thought I may as well check things out.
    I like what I see so now i am following you. Look forward to
    looking at your web page again.

  17. Thank you a bunch for sharing this with all folks you really understand what you’re talking approximately!
    Bookmarked. Please additionally seek advice from my site
    =). We will have a link alternate agreement between us

  18. says:

    Thanks for this great content. I really enjoyed
    it lots. What you have done is really inspirational.

    This is really inspirational content. I would like to use
    your style to improve my own content on my website.

    my weblog … salsa dance lessons;,

  19. You were able to redeem their value and you feel happy to know that you have saved some
    money. Pizza Delivery Driver Secret #9: Once a pizza delivery driver, always a
    pizza delivery driver. As you’ll be able to see, this allows you to maximize your time and money.

    Here is my page Dominos voucher

  20. With havin so much content do you ever run into any problems of plagorism or copyright violation?
    My site has a lot of unique content I’ve either
    created myself or outsourced but it looks like a lot of it is popping it
    up all over the web without my permission. Do you know any methods
    to help protect against content from being ripped off? I’d genuinely appreciate

  21. I’m gone to say to my little brother, that he should also go
    to see this blog on regular basis to get updated from hottest news update.

  22. hair shaper says:

    Hey I know this is off topic but I was wondering if you knew
    of any widgets I could add to my blog that automatically tweet my newest twitter updates.
    I’ve been looking for a plug-in like this for quite
    some time and was hoping maybe you would have some experience
    with something like this. Please let me know if you run into anything.
    I truly enjoy reading your blog and I look forward to your new updates.

  23. Heya i’m for the primary time here. I came across this board and I to find It truly helpful & it helped me out a lot.
    I am hoping to present something again and aid others like you helped

  24. Marisol says:

    Hey There. I discovered your weblog the usage of
    msn. That is an extremely smartly written article.

    I will be sure to bookmark it and return to read more of your useful information.
    Thanks for the post. I’ll definitely return.

  25. PS4 says:

    Since the admin of this web page is working, no uncertainty very rapidly it will be well-known, due to
    its feature contents.

  26. Do you mind if I quote a couple of your posts as long as I provide credit
    and sources back to your webpage? My blog is in the very same niche as yours and my visitors would
    truly benefit from some of the information you present here.
    Please let me know if this okay with you. Appreciate it!

  27. ooga says:

    It’s amazing designed for me to have a website, which is good designed for my knowledge.
    thanks admin

    Feel free to visit my webpage: ooga

  28. I have been surfing online more than three hours today, yet I never found any fascinating
    article like yours. It is beautiful value enough for me.
    In my opinion, if all website owners and bloggers
    made good content as you did, the internet can be a
    lot more useful than ever before.

  29. Increase the Town hall: Another important
    fact that players prevent when they are selected and they are as weak as any weak base can be.
    How many of you are probably thinking Who needs a guide for Clash of Clans has ranked as the #1 grossing app overall on iPad in 135 minecraft free download countries,
    according to App Annie.

  30. What’s up to every body, it’s my first go to see
    of this web site; this blog includes awesome and actually
    fine data for visitors.

  31. says:

    The card is capable of three way SLI (the SLI slots are hidden behind a
    rubber closure), but I can not stop myself from questioning in how many motherboards you can
    use three of this graphics card. There are many console game players who were
    never able to enjoy the original Crysis. In a smart move that allows Crytek to reset the story for new players, Crysis 2
    shifts the setting from a tropical island to a near-future (and stunningly rendered)

    my blog :: Crysis 3 crack – -

  32. Chat space is a cyber area which serves as a platform for web surfers to interact with one particular one more.
    Occasionally, a landlord will rent to you if you can get a cosigner under certain conditions.
    Dwell mature intercourse webcam will display you the seventh heaven
    and you also will drool like a mad dog.

  33. Your mode of describing everything in this piece of writing is in fact
    fastidious, every one be capable of effortlessly understand
    it, Thanks a lot.

    Take a look at my web-site :: luxury home accessories

  34. whoah this blog is excellent i like reading your posts.
    Keep up the great work! You understand, a lot of persons are hunting around for this information,
    you can help them greatly.

Leave a Reply