4 echo "Usage: $0 svn_url [dir]" >&2
10 if [ ! -f authors.txt ]; then
11 echo "Run \"get-authors $1\" first" >&2
21 if [ -z "$dir" ]; then
22 echo "Usage: $0 $url dir" >&2
27 git svn clone "$url" --authors-file=authors.txt --prefix=svn/ --stdlayout "$dir" &&
30 # Convert branches and tags
32 # See http://blog.jessitron.com/2013/08/converting-from-svn-to-git.html
34 git for-each-ref --format="%(refname:short)" refs/remotes/svn |
35 sed 's#svn/##' | grep -v '^tags' |
36 while read aBranch; do git branch $aBranch svn/$aBranch || exit 1; done
38 # See http://thomasrast.ch/git/git-svn-conversion.html
40 git for-each-ref --format="%(refname:short)" refs/remotes/svn/tags/ |
42 GIT_COMMITTER_DATE="`git log -1 --pretty=format:\"%ad\" \"$tag\"`" \
43 GIT_COMMITTER_EMAIL="`git log -1 --pretty=format:\"%ce\" \"$tag\"`" \
44 GIT_COMMITTER_NAME="`git log -1 --pretty=format:\"%cn\" \"$tag\"`" \
45 git tag -a -m "`git for-each-ref --format=\"%(contents)\" \"$tag\"`" \
46 "`echo \"$tag\" | sed 's#svn/tags/##'`" "$tag" || exit 1
49 # convert svn:ignore to .gitignore
50 git svn create-ignore &&
51 git commit -m "Add .gitignore"
53 # preserve authors.txt
54 cp -p ../authors.txt .git/info &&
55 git config --local --path svn.authorsfile .git/info/authors.txt
58 git repack -a -d -f --depth=250 --window=250 &&
59 echo "Cloned from $url using git-svn" >.git/description &&
60 exec "${VISUAL:-${EDITOR:-vi}}" .git/description