Skip to content

Instantly share code, notes, and snippets.

@hydra1983
Last active August 29, 2015 14:03
Show Gist options
  • Save hydra1983/55c6920af65edf0f33ec to your computer and use it in GitHub Desktop.
Save hydra1983/55c6920af65edf0f33ec to your computer and use it in GitHub Desktop.
# git_svn_repo should be a clean svn repository
git_svn_repo=<path>
git_repo=<path>
git_remote_repo=<url>
git_user_email=<email>
git_user_name=<name>

cd $git_svn_repo

## Prepare svn repo

# Ignore git related files for svn
# Add more ignores here
# Should append ignores automatically
cat <<EOF > __svn_ignores__
.git
.gitignore
.idea
product-build.iml
EOF
svn propset svn:ignore -F __svn_ignores__ .
rm __svn_ignores__

## Prepare git-svn repo
# Ignore svn related files for git
# Add more ignores here
# Should generate from svn ignores automatically
echo ".svn" >> .gitignore

git init
git config user.email "$git_user_email"
git config user.name "$git_user_name"

git add -A .
git commit -m "INIT REPO"

## Setup git repo
git clone $git_svn_repo $git_repo
git remote add upstream $git_repo

cd $git_repo
git config user.email "$git_user_email"
git config user.name "$git_user_name"
git remote remove origin
git remote add origin $git_remote_repo
git push -u origin master

## To merge changes from svn to git
cd $git_svn_repo
svn up
git add -A .
git commit -m "SVN UPDATE"
git push upstream master

## To merge changes from git to svn
cd $git_svn_repo
git pull upstream master
svn add .
svn commit -m "<your commit message here>"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment