Extract an SVN subtree - Import into Git

From Attie's Wiki
Jump to: navigation, search

This script will extract a subtree from the SVN repository in 'svnRepo', and import it into a new Git repository that can be found in 'gitRepo'

It is built from scripts found on SVN and Git

#!/bin/bash
 
if [ "$EXTRACT_PATH" = "" ]; then
  echo "Please provide \$EXTRACT_PATH"
  exit 1
fi
 
svnadmin dump ./svnRepo > extracted
 
cat extracted | svndumpfilter include --drop-empty-revs --renumber-revs "$EXTRACT_PATH" > filtered
 
cat filtered | awk "BEGIN{p=1}{
                 if (p == 1) {
                    if (\$0 == \"Node-path: $EXTRACT_PATH\") p = 0;
                    if (p == 1) print \$0
                 } else {
                   if (\$0 == \"PROPS-END\") p = 1
                 }}" > filtered2
 
cat filtered2 | sed -re "s#^(Node(-copyfrom)?-path): $EXTRACT_PATH#\\1: #" > relocated
 
svnadmin create ./freshRepo
 
cat relocated | svnadmin load --ignore-uuid ./freshRepo
 
rm filtered filtered2 relocated
 
git svn init file://`pwd`/freshRepo --no-metadata ./gitRepo
 
cd gitRepo
 
git config svn.authorsfile ../users.txt
 
git svn fetch
Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox