Automatically sync Git to SVN

Summary:

What I’d like to accomplish is to periodically push a bare Git repository into Subversion so others can examine it, using an unattended script. I don’t need the opposite direction, SVN -> Git.

I hope someone will help me get this done. The other threads I’ve seen are oh-so-close to what I need, but none have the full, plausible solution. Pushing an existing git repository to SVN was extremely helpful.

  • Stop tracking and ignore file as if it were never added in Git
  • Tracking changes using git during code review (stash vs. branch)
  • git subtree: possible to change subtree branch/path in a forked repository?
  • github picks up entire commit history
  • Does the folder I am in have any significance in git?
  • Why does terminal become unresponsive after I use certain git commands?
  • My problem:

    My employer maintains a Subversion server that has offsite backup, has redundancies, and is accessible by a web interface so my coworkers and managers can do casual reviews.

    I have six projects under Git. (I have multiple machines, I do lots of speculative branching, and I commit frequently. Also, Xcode just works better with Git. Our SVN administrator agrees that Git is all but nonnegotiable for me.) I’ve been doing this by keeping a bare repo on my desktop machine (owned by my employer and on its premises) which all working copies track.

    My employer would really prefer I didn’t do that; if he could provide an IT-grade Git server, he would. His compromise is that I find a way to get a launchd (cron) task to sync my desktop’s bare Git repo to a parallel repo on the SVN server.

    My proposed approach (probably unsatisfactory):

    I haven’t found any guides to cloning bare Git repos to Subversion, still less doing it unattended. My guess is that I have to do everything by way of a working copy, for which SVN syncing (but maybe not automation) is a solved problem.

    My naïve process is:

    1. Clone a working copy that is never edited into /dont-touch, from the bare repo.
    2. While in the no-edits /dont-touch directory, git svn init <svn-url> -s
    3. Do the necessary git svn fetch and git svn rebase dance.
    4. Every night, per a script fired by launchd:
      4.1. cd /dont-touch
      4.2. git fetch
      4.3. git svn dcommit

    The problems, as I see them:

    I’m ignorant

    Enough said.

    This category includes all the things I haven’t thought of.

    Interactivity

    Our hope is that we can set this up, let the sync script fire every 24 hours, and forget it.

    SVN authentication will, I assume, be cached and take care of itself after the first time it goes through, during the manual (1-3) setup. Git authentication would not be an issue, as the dont-touch working copy would be owned by the same user as the bare repo, and can be reached by file:///.

    But my impression of syncing Git to SVN is that it is fragile, and will need interactive nips and tucks to avoid damaging the SVN repo, much less simply getting it to work.

  • Cannot continue git rebase
  • Why does git revert complain about a missing -m option?
  • How to get the Git hash of the current working directory?
  • git creates files ending in ~?
  • github locks up mac terminal when using pull command
  • Does git lfs support local or “near” secondary storage \ cache?
  • One Solution collect form web for “Automatically sync Git to SVN”

    You may have a look at SubGit as git-svn replacement. Since 2.0 it allows to link local Git with remote Subversion repository. You run once:

    $ subgit configure --svn-url <URL_of_SVN_project_root> repos.git
    # edit repos.git/subgit/config, repos.git/subgit/authors.txt, and repos.git/subgit/passwd
    
    $ subgit install repos.git
    # now just work with repos.git as with usual git repository, but prefer "git pull --rebase" rather that "git pull" and "git merge --no-ff" rather than "git merge"
    

    where URL_of_SVN_project_root is the URL that contains trunk/branches/tags directories.

    Then clone the repository ‘repos.git’ and push/pull from/to it (optionally setup the working copy git config this way). Special Git hooks in ‘repos.git’ will synchronize it with SVN. Note that currently SubGit 2.0 is at eap stage, but I think it’s more reliable that git-svn setup you described.

    Git Baby is a git and github fan, let's start git clone.