git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: SVN migration

From
WHWilliam Hall <will@gnatter.net>
Date
Jun 17, 2010, 16:27 UTC
Message-ID
<4C1A4CF6.9080300@gnatter.net>
In-Reply-To
<4C19FA07.9010603@gnatter.net>

I'm going to answer my own post, I *think* I have something that works - please check if I'm doing anything idiotic.

Just to recap: trying to convince my company to move from svn to git, and they have agreed to try one project using git as long as all commits find their way to the svn repo as well.

So I have a standard bare git repo serving the developers, a git/svn "bridge" repo that performs bi-directional updates to and from svn and the bare git repo.

Ok, here's what I've done

Create bridge ------------- $ git svn init -s file:///path_to_svn /path_to_git_svn_bridge/ $ cd /path_to_git_svn_bridge $ git svn fetch --authors-file=/tmp/authors.map

Configure bare repo ------------------------------- create bare repo that developers will use $ git init --shared=all --bare /path_to_git_repo.git

configure bridge ---------------- $ git remote add -f -m master origin /path_to_git_repo.git $ git push origin master $ git branch --set-upstream master origin/master

this branch will be used to perform svn rebases and fetches $ git checkout -t -b svn svn/trunk

Workflow -------- Developer A clones from /path_to_git_repo.git, does some work, commits and pushes back to origin

Now, in the bridge repo, fetch changes from origin (where developer A pushed) $ git checkout master $ git pull

Replay all changes manually, in order, onto svn branch
$ git checkout svn
$ git rev-list --reverse heads/master@{1}..heads/master | while read rev; do
         git cherry-pick -n $rev
   done

Create one commit for all changes and synchronise with svn $ git commit -am "cherry pick merge" $ git svn rebase $ git svn dcommit

Now merge in anything picked up from svn, plus the rebased final commit $ git checkout master $ git merge svn

Send back to bare repo (at least the final merge commit) $ git push

It seems to handle changes and preserves linear history on both sides ok. Can anyone see anything obviously wrong with this approach?

thanks,
Will
William Hall wrote:
 > Thanks Steven,
 >
 > The noMetadata option will prevent me from doing anything other than 
a one-shot import, which is not what I want. I need to somehow devise a 
workflow that allows me bidirectional push/pull between an svn repo and 
a remote git repo.
 >
 >
 >
 > Steven Michalske wrote:
 >> On Jun 16, 2010, at 4:02 PM, William Hall wrote:
 >>
 >>> The issue is the dcommit operation from the bridge. The rebase part 
of this re-writes the commit messages to include the SVN commit-ids 
which is nice, but screws up the push/pulls between the bridge and the 
bare repo.
 >>
 >> Look into svn.noMetadata configuration option.  It will prevent you 
from rebuilding the svn to git bridge if something seriously goes wrong, 
but it prevents the messages from changing.
 >>
 >> svn-remote.<name>.noMetadata
 >> This gets rid of the git-svn-id: lines at the end of every commit.
 >> If you lose your .git/svn/git-svn/.rev_db file, git svn will not be 
able to rebuild it and you won't be able to fetch again, either. This is 
fine for one-shot imports.
 >> The git svn log command will not work on repositories using this, 
either. Using this conflicts with the useSvmProps option for (hopefully) 
obvious reasons
 > --
 > To unsubscribe from this list: send the line "unsubscribe git" in
 > the body of a message to majordomo@vger.kernel.org
 > More majordomo info at  http://vger.kernel.org/majordomo-info.html
William Hall wrote:
Show 33 quoted lines
> Thanks Steven,
> 
> The noMetadata option will prevent me from doing anything other than a 
> one-shot import, which is not what I want. I need to somehow devise a 
> workflow that allows me bidirectional push/pull between an svn repo and 
> a remote git repo.
> 
> 
> 
> Steven Michalske wrote:
>> On Jun 16, 2010, at 4:02 PM, William Hall wrote:
>>
>>> The issue is the dcommit operation from the bridge. The rebase part 
>>> of this re-writes the commit messages to include the SVN commit-ids 
>>> which is nice, but screws up the push/pulls between the bridge and 
>>> the bare repo.
>>
>> Look into svn.noMetadata configuration option.  It will prevent you 
>> from rebuilding the svn to git bridge if something seriously goes 
>> wrong, but it prevents the messages from changing.
>>
>> svn-remote.<name>.noMetadata
>> This gets rid of the git-svn-id: lines at the end of every commit.
>> If you lose your .git/svn/git-svn/.rev_db file, git svn will not be 
>> able to rebuild it and you won't be able to fetch again, either. This 
>> is fine for one-shot imports.
>> The git svn log command will not work on repositories using this, 
>> either. Using this conflicts with the useSvmProps option for 
>> (hopefully) obvious reasons
> -- 
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous: William HallNext: Joshua Shrader
Message 4 of 10 in “SVN migration”
  1. William HallJun 16, 2010
  2. Steven MichalskeJun 17, 2010
  3. William HallJun 17, 2010
  4. William HallJun 17, 2010
  5. Joshua ShraderJun 21, 2010
  6. William HallJun 21, 2010
  7. William HallJun 26, 2010
  8. David BainbridgeJul 3, 2010
  9. William HallJul 4, 2010
  10. David BainbridgeJul 4, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.