I'm trying to convert an SVN repo over to multiple git repos. So far I have been using git svn clone svn_repo_project_path
for each project in SVN. I have noticed that git does not seem to follow svn copy operations so the resulting history is much briefer than I expect. Suppose my SVN repo looked like this:
root
Projects b
and c
were recently copied under parent-proj
as part of a restructuring effort with the intention of eventually deleting them from their old locations under root. When I do git svn clone http://svnhost/parent-proj
the resulting git repo is missing all of the history that originated from /b
and /c
before the move.
Is this a limitation of git-svn or is there some way to get this history to show up in my repo? From my limited research it seems that using the filter-branch
command as described in Getting complete history of an SVN repo that's been renamed using git-svn may work although in my case there are multiple parents which probably complicates things. Could cloning the entire repo first and then splitting out new repos from it (using filter-branch?) be a better approach?
git svn clone
) today, so I searched stackoverflow and came across http://stackoverflow.com/questions/4908336/can-git-really-track-the-movement-of-a-single-function-from-1-file-to-another-i which showed me git blame -C MyFile
which gave me the blame history of the function I wanted all the way back to the original file (which was in a different directory) that this file was copied from (the original file still exists in the new directory today but those lines are no longer in it) - Shadow Man 2013-10-03 23:55
git svn clone -s svn://myserver/myproject
(note the lack of /trunk
) in case that matters - Shadow Man 2013-10-04 01:43
mainProj/trunk/module[AB]
into moduleA/trunk
and moduleB/trunk
) you will not get the history of anything before the split. But if your whole project was copied (mainProj/trunk
into newMainProj/trunk
) then you should get the full history - Shadow Man 2013-11-12 23:23
svn log
and svn log --stop-on-copy
and compare results - Patryk Obara 2014-03-04 14:28
You will not get pre-copy-to-parent-proj history for b
or c
if you git svn clone http://svnhost/parent-proj
. git svn
interprets your supplied base-path as the shallowest-point you are interested in ingesting the SVN commits for, making Git commits for the same. As the historical commits under b
and c
are outside of this path, git svn
won't mirror them, so you won't have that history.
Take a look at the documentation for the git svn init --no-minimize-url
option:
When tracking multiple directories (using --stdlayout, --branches, or --tags options), git svn will attempt to connect to the root (or highest allowed level) of the Subversion repository. This default allows better tracking of history if entire projects are moved within a repository, but may cause issues on repositories where read access restrictions are in place. Passing --no-minimize-url will allow git svn to accept URLs as-is without attempting to connect to a higher level directory. This option is off by default when only one URL/branch is tracked (it would do little good).
Since your clone
command does not specify multiple branches (perhaps because you have a complex, multi-project or non-standard layout), git svn
just clones commits involving that path and downwards. Shadow Creeper in comments used the -s
or --stdlayout
option, which can explain why some history was preserved for them.
If this is a one-off conversion (one-way move from SVN to Git), then you should probably clone the entire repository, then you have good options for moving things around in Git to look the way you want them to, including the establishment of historical branches and tags. If the motivation to run filter-branch
is to save repository space, make sure that this is going to actually save you something, and that it is worth the bother. Git is very efficient with storage.
One final word of caution on expections of history-searching in the Git clone. Look for history on a file using git log -C --follow <file-path>
and Git will typically do a good job of locating and providing you with a history incorporating renames and copies. Don't expect the same for directories, e.g. parent-proj/b
. Git tracks blobs (files), trees (of blobs), commits and parent commits, but does not handle directories or directory-copies in the same way as SVN.
git svn clone
also tracked projects outside of the directory being cloned (where they originated from) - Shadow Man 2013-08-31 02:11