"how do i convert an svn repo to git using reposurgeon?" Code Answer


it seems like the site is a bit outdated.

svnpull is replaced by repopuller by now. and you don't need that either if you are on the same server.

i adapted the script:

nano /usr/local/sbin/reposurgeon-convert-svn2git

and entered:

# or something like svnrepo=https://svn.origo.ethz.ch/$project


cd /tmp

# start over with:
#rm $project-mirror/ $project-git/ -rf

echo pull/copy the repository...
#repopuller $svnrepo
# or copy it if it is on the same server:
cp -av /var/svn-repos/$project /tmp/$project-mirror
echo start conversion...

reposurgeon <<eof
read /tmp/$project-mirror
prefer git
references lift
rebuild $gitrepo
echo ...finished 

# now filter out all falsly generated .gitignore files:
cd $gitrepo/
git filter-branch --force --index-filter      
 "git rm --cached --ignore-unmatch $(find . -name .gitignore|xargs )"  
 --prune-empty --tag-name-filter cat -- --all

i filter out the .gitignore files like github has documented with filter-branch because otherwise, they will create commits in all tags (see note below). you have to create a new .gitignore file when you are done.

this may take a while, so you should start it inside tmux or screen with

bash /usr/local/sbin/reposurgeon-convert-svn2git

take care, that all your tags are git conform.

i got the error

reposurgeon% reposurgeon: exporting...fatal: branch name doesn't conform to git standards: refs/tags/version 3.6.2

so i cleaned up the svn repository and removed this branch, so all tags and branches are conform:

svn rm "$svnrepo/tags/version 3.6.2"

and deleted it from all history with this script: how do i remove an svn tag completely that contains spaces?

then i started over with the script:

rm $project-mirror/ $project-git/ -rf
bash /usr/local/sbin/reposurgeon-convert-svn2git

without removing the .gitignore files, it looks all the same in git as in svn before except one thing: all tags are ordered in the log at the exact date they were tagged, instead of the commit they started ad. it seems a .gitignore file is added there in the conversion process to each branch and tag, but that .gitignore-file results in a commit inside those tags with the timestamp of the tag-creation.
new tags are ok, they appear right at the revision they belong to. (see convert an svn repository to git with reposurgeon without creating .gitignore files?)

By dsesto on March 10 2022

Answers related to “how do i convert an svn repo to git using reposurgeon?”

Only authorized users can answer the Search term. Please sign in first, or register a free account.