Skip to content

Instantly share code, notes, and snippets.

@FabienArcellier
Last active December 15, 2015 15:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FabienArcellier/5284301 to your computer and use it in GitHub Desktop.
Save FabienArcellier/5284301 to your computer and use it in GitHub Desktop.
This bash snippet is a script to migrate svn repository with a structure (trunk, branches and tags) to a new git repository. It take care of doing authors matching and remove the adress of old svn
#!/bin/bash
# This snippet suppose the file authors_list exists
# take a look at http://www.yterium.net/Migrer-un-projet-SVN-vers-GIT
if [[ "$1" == "" && "$2" == "" ]] ; then
echo "$1"
echo "$2"
echo "Arguments are invalid"
exit
fi
git svn --authors-file=authors_list clone $1 $2 --trunk=trunk --branches=branches --tags=tags
cd $2
git filter-branch -f --msg-filter 'sed -e "/git-svn-id:/d"' -- --all
#remove historics backups done by the command git filter-branch (I am not sure it's a good pratice)
sudo rm -Rf .git/refs/original/refs/
cd ..
echo "Migration $2 ended"
@FabienArcellier
Copy link
Author

author_list : text file with this format

svn_pseudo = git_pseudo 
farcellier = FabienArcellier <>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment