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

Migrating SVN to Git, and preserve merge information

From
Nick Douma <n.douma@nekoconeko.nl>
Date
Apr 10, 2012, 15:18 UTC
Message-ID
<4F844F33.5000004@nekoconeko.nl>
Hi,

I currently have two SVN repositories I'm looking to convert to Git. While the process itself isn't all that hard (following this guide[1]), I'm looking to do a bit more than just convert raw commits.

The repositories basically have two main branches at a time, for example:
* trunk
* current version, for example 3.5

Our SVN workflow consisted of working on trunk, and then manually merging single commits from trunk to the other branch. We quite consistently mentioned the merged commits in the SVN commit message, and I'm looking to use this information to generate a more accurate tree in Git. The commit messages are for example:

trunk rev 100: Fixed important bug branch rev 101: Merged r100 from trunk

Or more elaborate:
branch rev 200: Merged r100,r101,r.... from trunk

In these examples, tools like gitk or git log should show a line from rev 100 to rev 101 in the first example, and lines from r100, r101,rn to rev 200 in example two.

I have tried to create a custom grafts file to create the parent-child relations above, and basically finds all merge commits and converts them into graft lines like so:

<merge commit sha hash> <original git parent sha hash> <sha hash of merged rev 1> ... <sha hash of merged rev n>

This all works to a certain extent, but the problem arises when trying to view older history in these repositories. If I use the grafts file, and do `gitk --all`, gitk freezes. Gitg doesn't show commits before a certain point. tig and `git log --graph` all show a huge amount of parentless commits near the bottom. All of this leads me to the conclusion that something is wrong with the method of using grafts, rather than problems in the individual tools.

Can someone find something obvious that I'm missing in the above approach? Or alternatively suggest another more appropriate method of achieving the same results in Git?

Kind regards,
Nick Douma
[1]: http://john.albin.net/git/convert-subversion-to-git
Next: Andrew Sayers
Message 1 of 5 in “Migrating SVN to Git, and preserve merge information”
  1. Nick DoumaApr 10, 2012
  2. Andrew SayersApr 10, 2012
  3. Nick DoumaApr 11, 2012
  4. Santi BéjarApr 11, 2012
  5. Andrew SayersApr 11, 2012

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.