Trying to convert a SVN repo to Git. The Ruby version works, but does not commit all the files with the correct CRLF chars – seems to ignore the global settings.
svn2git http://svnhost.xx.com/svn/repo/mobile/circdesk-android/trunk --rootistrunk --verbose > x
I can reconvert the repo afterwards to fix the endings (see this) but it makes diffing before and after tricky. Tried to hack the Ruby code to add “text = *” to the .gitattributes file. No dice.
So I tried another version of svn2git based on Qt. First, use Linux. Windows would have no chance.
Installed the Qt libs. I build subversion, apr, and aprutil from scratch, and then link failed. Tried:
export LD_LIBRARY_PATH=/usr/local/lib export QTDIR=/home/dchwalis/tools/QtSDK/Desktop/Qt/4.8.1/gcc
Changed all the APR includes to local
# must use local APR APR_INCLUDE = /usr/local/apr/include/apr-1 APR_LIB_DIR = /usr/local/apr/lib APR_UTIL_INCLUDE = /usr/local/apr/include/apr-1 APR_UTIL_LIB_DIR = /usr/local/apr/lib
and rules :
create repository demo-convert end repository match /trunk/ repository demo-convert branch master end match
So it compiled and linked. But when I run I got an error message, basically SVN could not use the
"http:" access method. Looks like I was missing the neon lib. (
ra_neon). Download and build neon. No change. Sigh.
apt-get all the -dev versions of subversion, APR, and APR-util. Changed all the APR includes to local
SVN_INCLUDE = /usr/include/subversion-1 APR_INCLUDE = /usr/include/apr-1.0/ APR_LIB_DIR = /usr/lib SVN_LIBDIR = /usr/lib
Now it works, but there is a problem with the SVN itself.
Invoked as:' ./svn-all-fast-export --rules=rules http://svnhost.xx.com/svn/repo/etl/trunk' WARNING; no identity-map specified, all commits will be without email address Loading rules from "rules" svn: Can't open file 'http://svnhost.xx.com/svn/repo/etl/trunk/format': No such file or directory Failed to open repository
Sigh. I give up.
Then I found this article which I adopted for an Android project.
. I first had to install tofrodos to allow fromdos and then ran it.
First you gotta clear up the newline problem on the HEAD. So use Renormalizing a repo
The final commit shows the items not in the script, and you can fix and redo.
a. We have two stupid commits at the end, one to redo the CRLFs, which we had to do, and one to remove the x file committed in error.
b. There is a whole bunch of original commits in the repo which are the original versions of the commits. Note that all the SHAs have changed in your new tree. That is why you never do this to a repo that others have cloned and are working on.
To remove the commits for a)
1. Save the commit on a branch from gc (optional)
2. Ditch that commit on this branch
3. Repeat for the number of additional commits. Two when you commit x.
(Thanks to this article)
To remove the junk commits.
1. Remove all the tags and branches on this old commits.
remove the lines like refs/original/refs/*
2. git gc
3. They fall off of the tree.
And don’t forget on the remote repo the configs
git config core.sharedRepository "all"and
git config receive.denyNonFastForwards true. Else you can pull but not push.