3

I'm trying to (permanently) migrate my group's Subversion repository to Git, but I'm running onto problems trying to clean up its non-standard directory structure.

Some of the project's content is contained in trunk and branches folders, but not all of it. The project on Subversion is laid out like this:

project/trunk/
project/branches/feature_1
project/branches/feature_2
project/libraries
project/crontab
...

After importing, I want the Git repository to be laid out like so:

project/html # the content of the old trunk and branches folders
project/libraries
project/crontab
...

Running svn2git with the appropriate options will handle the trunk and branches directories correctly, but how can I also include the history for the other folders? It seems like git-filter-branch could help, but I'm not sure how to use it for this.

Eric Naeseth
  • 2,293
  • 2
  • 19
  • 18
  • 1
    The (http://stackoverflow.com/questions/614229/can-i-move-the-git-directory-for-a-repo-to-its-parent-directory) may help. – VonC Oct 12 '10 at 04:15
  • 1
    why not you make a 'svn move' to get the appropriate structure and then do a svn2git ? you will still have the history right ? – Version Control Buddy Oct 12 '10 at 12:54
  • @Version Control Buddy: After the import, the Git repository will consider the old `project/trunk` folder to be its root. Folders `svn move`d into trunk before the import will have history, but their original locations will still be outside the root of the repository, and they will be ignored. – Eric Naeseth Oct 14 '10 at 01:09
  • I feel it would not get left out, but I dont have the time now to validate my statement. However, check this out http://stackoverflow.com/questions/1292531 this seems similar to your requirement. – Version Control Buddy Oct 14 '10 at 03:48
  • possible duplicate of [When converting from svn to git using git-svn or svn2git, how can I change the base path of the repository and possibly still keep branches/tags?](http://stackoverflow.com/questions/1292531/when-converting-from-svn-to-git-using-git-svn-or-svn2git-how-can-i-change-the-ba) – gbjbaanb Apr 08 '11 at 19:02
  • @EricNaeseth You said "Folders `svn move` d into trunk before the import....will be ignored." - would this mean that `git blame` wouldn't work for those folders? Just as [this question](http://stackoverflow.com/q/6986090/277208) asks about. – Jon Stafford Sep 20 '11 at 13:47

1 Answers1

1

Import each main subfolder of your repo into a separate git repo and then use the subtree merging method to merge the git repos into one repo. You may end up with a few duplicate commits though.

If you have many subdirectories you may want to do an svnadmin dump, then svndumpfilter exclude .. twice to split your svn repo into two halves and then use the subtree merging method to re-join them. This would have a cleaner history than doing many subtree merges.

Community
  • 1
  • 1
ColinM
  • 13,367
  • 3
  • 42
  • 49