Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6648527
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:39:56+00:00 2026-05-26T00:39:56+00:00

My project has a Subversion repository on a network file system, and a new

  • 0

My project has a Subversion repository on a network file system, and a new team would like to access it using Git, and be able to commit to it and get updates from it.

What I have in mind is to create a new bare git-svn clone of the Subversion repository on the same network file system, and make sure the two repositories are always up to date with respect to each other.

The way to do this is probably to add a post-commit hook for both Subversion and the new Git repository, that will each update the other’s repository.

The Subversion post-commit hook will include git svn rebase, and the Git one git svn dcommit.

The problem is that I will have to use some kind of lock to make sure no one commits to either repository while other is also being committed to, because they always have to be in sync before any commit. This has several disadvantages, among them the time it will take to commit to Subversion or to push to the Git repository (it has to wait for the hook to finish), and the fact that some users may not be able to run git svn (because it’s not installed on their machine), which means they can’t update the other repository when committing/pushing.

How can I solve these problems? What will the Subversion and Git hooks look like?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T00:39:56+00:00Added an answer on May 26, 2026 at 12:39 am

    Here is what I’ve come up with:

    1. Create the git-svn repository if it doesn’t exist already:

      git svn init --std-layout <svn_url> <git-svn_path>
      

      The master branch is created automatically to track the trunk.

    2. To avoid name ambiguities with Subversion-tracking branches, make the original Subversion branches show as remotes/svn/<branch name>: go to the newly-created git-svn repository and run

      git config svn-remote.svn.fetch trunk:refs/remotes/svn/trunk
      git config svn-remote.svn.branches branches/*:refs/remotes/svn/*
      git config svn-remote.svn.tags tags/*:refs/remotes/svn/tags/*
      
      rm .git/refs/remotes/*
      git svn fetch
      
    3. Create a Subversion-tracking branch for each Subversion branch:

      for BRANCH in $(svn ls <svn_url>/branches/); do
          git branch $BRANCH remotes/svn/$BRANCH
      done
      
    4. Make sure no non-Subversion-tracking branches are created on the central Git repository:

      # Used by hooks/update:
      git config hooks.denyCreateBranch true
      git config hooks.allowDeleteBranch false
      
      cp .git/hooks/update.sample .git/hooks/update
      chmod +x .git/hooks/update
      
    5. Allow pushing to the central Git repository:

      git config receive.denyCurrentBranch ignore
      git config receive.denyNonFastForwards true
      git config push.default current
      

      And create the post-receive hook to reset and send the commits to Subversion:

      cat .git/hooks/post-receive
      
          #!/bin/sh
      
          date >> receive.log
          git reset --quiet --hard
          while read LINE
          do
              BRANCH=${LINE##*/}
              echo Updating $BRANCH
              git checkout --quiet --force $BRANCH
              git svn dcommit
          done 2>&1 | tee -a receive.log
          git checkout --quiet --force master
      
      chmod +x .git/hooks/post-receive
      

      The reset is necessary, because otherwise the current branch is out-of-date after each receive.

    6. Finally, create the hook to get updates from Subversion:

      cat .git/hooks/svn-rebase-all
      
          #!/bin/sh
      
          date >> .git/svn-rebase.log
          git reset --quiet --hard
          for REF in .git/refs/heads/*
          do
              BRANCH=${REF##*/}
              echo Updating $BRANCH
              git checkout --quiet --force $BRANCH
              git svn rebase
          done 2>&1 | tee -a .git/svn-rebase.log
          git checkout --quiet --force master
      
      chmod +x .git/hooks/svn-rebase-all
      

      And call it from the Subversion post-commit hook:

      cat <svn_path>/hooks/post-commit
      
          cd <git_path>
          . .git/hooks/svn-rebase-all
      
      chmod +x <svn_path>/hooks/post-commit
      

    Instead of using a single git-svn central repository, one can use a bare central Git repository and an intermediate non-bare git-svn repository, as in this answer.
    I chose to use one non-bare git-svn repository which is also the central repository.

    Anyone can work on the project using Git by cloning <git_path> and pushing to it, or using Subversion by checking out <svn_url> and committing to it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to convert a CVS project to Subversion, using cvs2svn. It has a
I am using git to develop against a project hosted in subversion, using git-svn:
We have a non-standard subversion respository that we would like to convert to Git.
I created a new project, then I clicked on Import to Subversion repository but
I have a subversion repository that has a project that I updated to earlier.
I have a project in a directory projects/projectA. it has a corresponding subversion repository.
CentOS 5.3 subversion 1.4.2 Our company would like to know who has checked out
My project has both client and server components in the same solution file. I
So right now my project has a few custom dialogs that do things like
I am trying to clone a Subversion repository to git, but it keeps giving

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.