Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in DevOps and Agile by (19.4k points)

I read the Git manual, FAQ, Git-SVN crash course, etc. and they all explain this and that, but nowhere can I find a simple instruction like:

SVN repository in: svn://myserver/path/to/svn/repos

Git repository in: git://myserver/path/to/git/repos

git-do-the-magic-svn-import-with-history \

svn://myserver/path/to/svn/repos \

git://myserver/path/to/git/repos

I don't expect it to be that simple, and I don't expect it to be a single command. But I do expect it not to try to explain anything - just to say what steps to take given this example.

1 Answer

0 votes
by (119k points)
edited by

I used the following script to read a text file that has a list of all my SVN repositories and convert them to Git, and later use git clone --bare to convert to a bare Git repository:

#!/bin/bash

file="list.txt"

while IFS= read -r repo_name

do

 printf '%s\n' "$repo_name"

 sudo git svn clone --shared --preserve-empty-dirs --authors-file=users.txt file:///programs/svn/$repo_name

 sudo git clone --bare /programs/git/$repo_name $repo_name.git

 sudo chown -R www-data:www-data $repo_name.git

 sudo rm -rf $repo_name

done <"$file"

list.txt has the format:

repo1_name

repo2_name

And users.txt has the format:

(no author) = Prince Rogers <[email protected]>

www-data is the Apache webserver user. It needs permission to push changes over HTTP.

Also, check out this Git Tutorial to know more.

Browse Categories

...