I am trying to migrate a very old svn
repository to git
and to rearrange directory structure. Initially the svn
repository structure was like this.
Stage A
application/
.svn
dev/
dev1/
dev2/
test/
test1/
test2/
others/
others1/
others2/
Over some years, the structure changed to something like this.
Stage B
application/
.svn
dev1/
dev/
test/
others/
dev2/
dev/
test/
others/
Contents of
- dev/dev1 is moved to dev1/dev
- test/test1 is moved to dev1/test
- others/others1 is moved to dev1/others
Same movement is done for dev2 directory as well.
Now I have moved the source code to git
using git svn clone
, maintaining all commit history. Currently the directory structure is like this.
Stage C
application/
.git
dev1/
dev/
test/
others/
dev2/
dev/
test/
others/
Now I want to split this repository into two new repositories like this
Stage D
dev1/
.git
dev/
test/
others/
dev2/
.git/
dev/
test/
others/
I have tried git filter-branch subdirectory-filter
like this.
git filter-branch --subdirectory-filter dev1 --prune-empty
which successfully created the directory structure I wanted, maintaining all the commit history of dev1 upto the movement mentioned in Stage B
. All the commits before the movement mentioned in Stage B
is lost.
What I want to achieve is to create directory structure mentioned in Stage D
, maintaining all commit histories of all files which are present in dev1
and dev2
.
Important : Most of the files present in dev1
and dev2
are created even before the creation of dev1
and dev2
- those files are later moved to dev1
/dev2
.
In my opinion you should create 2 copies of the repository from stage C —
dev1
anddev2
. Then remove the directory dev2 from the repodev1
and remove the directory dev1 from the repodev2
. Then in both repositories move all subdirectories one level up and remove directories dev1 and dev2.Repeat the same for
dev2
exchanging dev2 and dev1.