I'm trying to migrate my svn repository to git repository using Atlassian tutorial (https://www.atlassian.com/git/tutorials/migrating-overview) and I'm failing to checkout my svn repository correctly. After cloning, it has all the history available when using git log
but I don't see any of the files. I've tried to checkout one of the remote branches with git checkout -b trunk remotes/trunk
but still no files on newly created branch trunk.
The migration script beginning looks like this:
#!/bin/sh
#$1 - remote svn repo
#$2 - local git repo name
java -jar svn-migration-scripts.jar authors $1 > authors.txt
git svn clone --stdlayout --authors-file=authors.txt $1 $2
What I've figured out
I can get hold of files without history by using git svn command:
git svn clone -rHEAD $1 $2
The files checked out with this command will have svn-like structure (trunk
, branches
), so that's not what I'm looking for.
Another try...
I've tried using svn2git
from GitHub, but it's using the same mechanisms, so it also fails... The command:
svn2git https://svn/xxx --trunk trunk/src --branches branches --notags --authors ../authors.txt
Output:
Checked out HEAD:
https://svn/xxxx r149793
Still no files, only .git
folder. I've tried fetching, pulling etc.
Another interesting observations
I've found one weird repository. There is folder structure like this:
* branches
* as usual...
* tags
* as usual...
* trunk
* src
* src
* pom.xml
The output is as follows:
svn2git https://svn/xxx --trunk trunk
svn2git https://svn/xxx --trunk trunk/
Doesn't work...
svn2git https://svn/xxx --trunk trunk/src
Works. That's at least very weird.
I don't know what exactly caused the problem, but it had something to do with my version of git. I've used git 1.9 on Ubuntu and it failed, but for the same command on OS X version of git (1.8) it worked. If you stumble upon such problem, try experimenting with other versions of git.
The script I've used for migration (svn-migration-scripts.jar
is jar downloaded from Atlassian tutorial)
#!/bin/sh
# $1 - remote svn repo (https://svn/path/to/repository)
# $2 - local git repo name (MyProject)
# $3 - remote git repo address (user@gitserver:/path/to/repository)
java -jar svn-migration-scripts.jar authors $1 > authorsTmp.txt
sed "s/mycompany\.com/youractualcompany.com/g" authorsTmp.txt > authors.txt
git svn clone -s --authors-file authors.txt $1 $2
cd $2
java -Dfile.encoding=utf-8 -jar ../svn-migration-scripts.jar clean-git --force
git remote add origin $3
git push -u origin --all
I hope somebody will find it helpful.