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

Re: Converting SVN repository to git

From
SKSeth W. Klein <sk@sethwklein.net>
Date
Jun 18, 2005, 03:26 UTC
Message-ID
<20050618032648.GA23034@bubook.sethwklein.net>
In-Reply-To
<20050615184720.GF31997@artsapartment.org>
On Wed, Jun 15, 2005 at 01:47:20PM -0500, Art Haas wrote:
Show 5 quoted lines
> 
> [....] I've not seen anything, though,
> on switching Subversion repositories to git. Has there been any public
> activity in writing a tool/script to do this? Perhaps some offline
> discussion about doing this?

The following script is what I used to convert a simple svn repository. It doesn't handle branches or tags and contains buggy use of grep and inscrutable uncommented use of sed but it should be a starting place for someone with a more complex repository available for testing.

export GIT_AUTHOR_EMAIL=sk@sethwklein.net
export GIT_COMMITTER_EMAIL=sk@sethwklein.net
svn co -r 1 file:///home/sk/rep/oakheart/trunk oakheart
cd oakheart
git-init-db
for REV in `seq 2 692`; do
    echo -n $REV' '
    svn update -r $REV > .svnupdate
    sed -nr 's/^A +//p' .svnupdate \
    | while read F; do [ -f "$F" ] && echo "$F"; done \
    | xargs -r git-update-cache --add --
    sed -nr 's/^D +//p' .svnupdate \ 
    | while read F; do git-ls-files | grep "^$F"'\(/\|$\)'; done \
    | xargs -r git-update-cache --remove --
    sed -nr 's/^U +//p' .svnupdate \
    | while read F; do [ -f "$F" ] && echo "$F"; done \
    | xargs -r git-update-cache --
    PARENT=
    [ -f .git/HEAD ] &&
        PARENT='-p '`cat .git/HEAD`
    svn log -r $REV | sed -n '1,3d;$d;H;/^$/!{s/.*//;x;s/\n//;p}' \
    | git-commit-tree `git-write-tree` $PARENT > .git/HEAD
done

Cheers, Seth W. Klein

-- 
sk@sethwklein.net     AIM: sethwklein     http://www.sethwklein.net/
Previous: Adam Mercer
Message 3 of 3 in “Converting SVN repository to git”
  1. Art HaasJun 15, 2005
  2. Adam MercerJun 15, 2005
  3. Seth W. KleinJun 18, 2005

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.