After trying several options and a bunch of hints from this site and others I'm stuck. My main question is the following: I'd like to migrate (part of) an SVN repository to Git, preserving history. The SVN layout is non-standard and after git svn clone
I do see the right branches appear, but when I try to e.g. merge master
into a branch, I get conflicts that say both added a set of files. If I take a look in e.g. gitg
I see the branches, but they never seem to branch from master
/trunk (so the "both added" conflicts seem logical from that perspective), nor do I see any of the merges (e.g. from trunk to a branch) in the graph (the commits are there, they just don't link to branches in the graphical display of gitg
). In fact, for some branches I even see two identical commits one after the other (one for master, one for the branch).
The way I created the branches in SVN was using svn copy
.
Some more details:
Repository layout: A slightly simplified schematic of the SVN repo layout (the structure is the same, names are different, some directories have been omitted)
pkg
Project1
Project2
Lib
branches
Project1-feature1
Project1
Lib
Project1-hotfix
Project1
Lib
Lib-feature
tags
Project1
v0.1.0
v0.2.0
Project1
Lib
Project2
v0.1.0
The Lib
directory is closely associated with Project1, but also used by others. That is why I (starting with v0.2.0) created to Project1
and Lib
subdirectory structure in the branches and tags.
My git svn
workflow: This is the most promising command I used to clone the SVN repo:
git svn clone \
--prefix=svn/ \
--trunk=pkg \
--branches=branches \
--tags=tags/Project1 \
-A authors.txt \
--ignore-paths='^pkg/(?!Project1|Lib)' \
svn+ssh://[email protected]/svnroot/MyTool SVN2GitMigration
The --ignore-paths
option is there so that I keep only the two directories (Project
and Lib
) in which I'm interested. I do not filter on branches since there is only one branch not directly related to Project1
.
After that I convert the remote branches to local branches (and remove the remote branches), then convert the tags to proper Git tags.
EDIT START: Closer inspection of the commits reveals that I have many empty commits. These turn out to be due to the --ignore-paths
option: the empty commits are done in parts of the directory tree that are ignored. So this option doesn't really behave as I expected.
Back to the drawing board...
EDIT END
EDIT2
Actually, using git filter-branch --tag-name-filter cat --prune-empty -- --all
I managed to remove the empty commits
EDIT2 END
Possible cause of my merge problems: Branches/Tags are not single SVN commits because they first consist of a commit in which I create the branches/Project1-featureX
directory, followed by two svn copy
lines in which I copy the Project1
and Lib
directories from trunk.
Suggestions on how to properly convert this SVN repo are very welcome! If, somehow this means loosing Lib
that isn't a big deal. I'm planning to separate the two anyway once the migration has finished.
Project1
,Project2
andLib
. After all they are supposed to be split into separate repositories in git.git svn clone --prefix=svn/ --trunk=pkg/Project3 -A authors.txt $SVNURL Project3_Git
. What complicates matters for Project1 is probably the way I created the branches. Or do I misunderstand your point?--branches=branches/Project1-*
for yourProject1
git svn
command above shows me that I have many commits that are empty. I think the--ignore-path
option is the cause. So... back to square one...