I import SVN repository using Subgit, which is an excellent tool doing it fast and supporting custom svn layout. Subgit saves git commit -> svn revision reference in git notes
. Every commit has revision number in notes, you can see it with git log
.
After SVN->git import I use BFG repo cleaner to clean old project repository from binaries like jars, dlls etc.
BFG does not rewrite links between git notes and changed commits but fortunately it leaves object-id-map.old-new.txt
file.
I use this file to copy notes from old commits to new ones:
cat object-id-map.old-new.txt | git notes copy --stdin
After copying notes i remove them from old objects:
cat object-id-map.old-new.txt | cut -d' ' -f 1 | git notes remove --stdin --ignore-missing
The problem is that after fixing git notes repository size becomes 2 times bigger (even if i clone without --bare
). Why?
Example: I have imported repo from svn with Subgit and have 400Mb .git
. Then i apply BFG and get 40 Mb bare repository. I want to restore git notes by moving (copying and removing) them with 2 commands above, but unfortunately repo's size grows from 40 Mb to 80 Mb.
I try to execute git notes prune
and git reflog expire --expire=now --all && git gc --prune=now --aggressive
which is recommended by BFG, but still have 80 Mb.
UPD: can't reproduce 40 Mb repo now:/ It is 80 after BFG cleanup and 86 after copying notes