Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base: df6368b94e
...
compare: d2debf709f
Checking mergeability… Don't worry, you can still create the pull request.
  • 3 commits
  • 2 files changed
  • 1 commit comment
  • 1 contributor
Showing with 79 additions and 1 deletion.
  1. +12 −1 README.textile
  2. +67 −0 git2svn.sh
View
13 README.textile
@@ -13,4 +13,15 @@ $ svn checkout https://myrepo.googlecode.com/svn/trunk/ svn_repo</pre>
2) Configure *git2svn.sh* variables (*GIT_DIR* and *SVN_DIR*) with locations of both repositories.
-3) Run the script from anywhere except one of these two directories.
+3) Run the script from anywhere except one of these two directories.
+
+h2. Example
+
+If you want to see an example migration, check the following repositories:
+
+Source: "http://github.com/acarlos1000/MemeiPad/commits/master":http://github.com/acarlos1000/MemeiPad/commits/master
+Destination: "http://code.google.com/p/memeipad/source/list":http://code.google.com/p/memeipad/source/list
+
+h2. Be careful
+
+This script will delete everything from your SVN repository when the first commit is migrated.
View
67 git2svn.sh
@@ -0,0 +1,67 @@
+#!/bin/bash
+BASE_DIR=`pwd`
+GIT_DIR="/Users/gc/Temp/git_repo"
+SVN_DIR="/Users/gc/Temp/svn_repo"
+
+# The SVN_AUTH variable can be used in case you need credentials to commit
+#SVN_AUTH="--username guilherme.chapiewski@gmail.com --password XPTO"
+SVN_AUTH=""
+
+function svn_checkin {
+ echo '... adding files'
+ for file in `svn st ${SVN_DIR} | awk -F" " '{print $1 "|" $2}'`; do
+ fstatus=`echo $file | cut -d"|" -f1`
+ fname=`echo $file | cut -d"|" -f2`
+
+ if [ "$fstatus" == "?" ]; then
+ if [[ "$fname" == *@* ]]; then
+ svn add $fname@;
+ else
+ svn add $fname;
+ fi
+ fi
+ if [ "$fstatus" == "!" ]; then
+ if [[ "$fname" == *@* ]]; then
+ svn rm $fname@;
+ else
+ svn rm $fname;
+ fi
+ fi
+ if [ "$fstatus" == "~" ]; then
+ rm -rf $fname;
+ svn up $fname;
+ fi
+ done
+ echo '... finished adding files'
+}
+
+function svn_commit {
+ echo "... committing -> [$author]: $msg";
+ cd $SVN_DIR && svn $SVN_AUTH commit -m "[$author]: $msg" && cd $BASE_DIR;
+ echo '... committed!'
+}
+
+for commit in `cd $GIT_DIR && git rev-list --all --reverse && cd $BASE_DIR`; do
+ echo "Committing $commit...";
+ author=`cd ${GIT_DIR} && git log -n 1 --pretty=format:%an ${commit} && cd ${BASE_DIR}`;
+ msg=`cd ${GIT_DIR} && git log -n 1 --pretty=format:%s ${commit} && cd ${BASE_DIR}`;
+
+ # Checkout the current commit on git
+ echo '... checking out commit on Git'
+ cd $GIT_DIR && git checkout $commit && cd $BASE_DIR;
+
+ # Delete everything from SVN and copy new files from Git
+ echo '... copying files'
+ rm -rf $SVN_DIR/*;
+ cp -prf $GIT_DIR/* $SVN_DIR/;
+
+ # Remove Git specific files from SVN
+ for ignorefile in `find ${SVN_DIR} | grep .git | grep .gitignore`;
+ do
+ rm -rf $ignorefile;
+ done
+
+ # Add new files to SVN and commit
+ svn_checkin && svn_commit;
+done
+

Showing you all comments on commits in this comparison.

@guilhermechapiewski

Don't use this unless you have a very good reason, like I did. And as I said in the docs, don't ask me why :)

Something went wrong with that request. Please try again.