How to run svn update in a loop to import commits to git?

Current setup
I am running a local git repository in parallel to a svn checkout in the same folder. Whenever something new happens on the svn server I run svn update to download the commits. Then I git add && git commit the whole set of changes to the git repository.

Task
I want to checkout each commit separately to being able to git add && git commit the change with the corresponding commit message from svn.

  • Can't push master branch to git repository with netbeans
  • Git merge only the final result of a development branch
  • Is there a way to test if a file is GPG encrypted in a git hook?
  • The Git client in Visual Studio 2013 is “offline”
  • Why is this refname ambiguous
  • Customs for submitting changes to an open source project?
  • Ideas
    I already found out that I can use svnversion to retrieve the revision numbers of the working copy and the server.

    // svnversion -h
    usage: svnversion [OPTIONS] [WC_PATH [TRAIL_URL]]
    
      Produce a compact 'version number' for the working copy path
      WC_PATH.  TRAIL_URL is the trailing portion of the URL used to
      determine if WC_PATH itself is switched (detection of switches
      within WC_PATH does not rely on TRAIL_URL).  The version number
      is written to standard output.  For example:
    
        $ svnversion . /repos/svn/trunk
        4168
    
      The version number will be a single number if the working
      copy is single revision, unmodified, not switched and with
      an URL that matches the TRAIL_URL argument.  If the working
      copy is unusual the version number will be more complex:
    
       4123:4168     mixed revision working copy
       4168M         modified working copy
       4123S         switched working copy
       4123P         partial working copy, from a sparse checkout
       4123:4168MS   mixed revision, modified, switched working copy
    
       ...
    

    Note
    I would be happy to discuss ideas with you to solve the task.
    A later setup would also include svn externals which is why I cannot checkout the svn repository via git-svn.

  • How to git clone a specific tag only without getting the whole repo?
  • With “git svn”, Can I Ignore Specific Git Commits While Fetching?
  • What are advantages of keeping linear history in git
  • Problems with git submodules when submodules are private Github repos
  • Git rebasing not working correctly?
  • Find out which remote branch a local branch is tracking
  • 3 Solutions collect form web for “How to run svn update in a loop to import commits to git?”

    There are two more options you might want to investigate:

    1. SmartGit

      SmartGit is Subversion + Git client, that means SmartGit works with local Git repository but you can add svn repository as a remote (similar to git remotes). SmartGit is much more superior than git-svn feature-wise. For more details please refer to SmartGit vs. git-svn comparison.

      In particular SmartGit does support both git submodules and svn externals pretty well, so you can even mix them.

      SmartGit is proprietary software but it’s free for non-commercial usage.

    2. SubGit

      SubGit is the server-side solution. That means you have to install SubGit and connect it to your Subversion repository that basically includes two steps:

      1. Perform initial translation of SVN repository via SubGit to freshly created Git repository.

      2. Install SubGit specific hooks which are triggered on every git push, so every change get synchronized between Git and SVN repositories.

    For more details you may refer to SubGit documentation.

    SubGit is proprietary software. SubGit is free for small teams with up to 10 committers and for academic and open-source projects.
    SubGit is also available as an add-on for the Bitbucket Server, to find out more check out here.

    DISCLAIMER:
    I’m SubGit developer and I work in a close contact with SmartGit developers. But these two projects seem very relevant to your particular case. Hope you’ll find my comment helpful.

    Well you can try git svn whose sole purpose is to work with SVN and Git simultaneously.

    Dont use svn directly. Here is all you need to setup and work with SVN and Git.

    http://progit.org/book/ch8-1.html

    I once created a “continous integration” like shell script which was basically an

    while true
    do
      sleep 42
      if svn up | grep '^. ' | egrep '^[ABDUCGE]*'
      # the first grep drops the "At revision xxx" line
      # the second grep searches for the update status codes
      then
        #do something
      fi
    done
    

    But I write this only from memory, maybe there are some other messages which svn up may produce`.

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