Saving SVN copy history when converting to git

I am trying to convert an SVN repo to multiple git repositories. So far I have used git svn clone svn_repo_project_path for each project in SVN. I noticed that git does not seem to perform the SVN copy operation, so the resulting story is much shorter than I expect. Suppose my SVN repo looked like this:

root

  • a
  • b
  • from
  • parent-designed
    • b
    • from

Projects b and c were recently copied under parent-proj as part of a restructuring effort with the intention of ultimately removing them from old places as root. When I do git svn clone http://svnhost/parent-proj , the whole git that came from /b and /c before the move is missing from the resulting git repo.

Is this a limitation of git-svn or is there some way for this story to appear in my repo? From my limited research, it seems that using the filter-branch command described in Getting the full SVN repo history, which was renamed with git-svn , might work, although in My case there are several parents that are likely to complicate the situation. Can cloning an entire repo first and then splitting new repositories from it (using a filter branch?) Is the best approach?

+6
source share
1 answer

If you git svn clone http://svnhost/parent-proj , you will not get a history with a copy-parent name for b or c . git svn interprets the base path you provided as the smallest point that you are interested in smoothing out the SVN record by doing Git for the same. Since the historical commits in b and c are outside this path, git svn will not reflect them, so you will not have this story.

Take a look at the documentation for the git svn init --no-minimize-url :

When tracking multiple directories (using the --stdlayout, --branches or --tags options), Git svn will try to connect to the root (or the most acceptable level) Subversion repository. This default value allows you to better track history if entire projects are moved to repositories, but can cause problems with repositories where read access restrictions exist. Passing --no-minim-url will allow Git svn to accept URLs as is, without trying to connect to a higher level directory. This option is disabled by default when only one URL / branch is tracked (this will be of little use).

Since your clone command does not specify multiple branches (possibly because you have a complex, multi-project or non-standard layout), git svn just clones the commit associated with this path down. Shadow Creeper used the -s or --stdlayout -s in the comments, which might explain why some kind of story was saved for them.

If this is a one-time conversion (one-way moving from SVN to Git), then you should probably clone the entire repository, then you have good options for moving things to Git to see the path you want them to, including creating historical branches and tags. If the motivation to run filter-branch is to preserve the repository space, make sure that it will actually save you, and that it is worth it. Git is very storage efficient.

One final warning about pending search history in a Git clone. Look for the history in the file with git log -C --follow <file-path> and Git, usually do a good job of finding and providing history including renames and copies. Do not expect the same for directories, for example. parent-proj/b . Git tracks drops (files), trees (from blocks), commits and parent commits, but does not treat directories or directory copies in the same way as SVN.

0
source

Source: https://habr.com/ru/post/916130/


All Articles