Skip to content

Instantly share code, notes, and snippets.

@janwirth
Created August 21, 2017 14:50
Show Gist options
  • Save janwirth/e21fa2a8b0733ad7803e3694afe35874 to your computer and use it in GitHub Desktop.
Save janwirth/e21fa2a8b0733ad7803e3694afe35874 to your computer and use it in GitHub Desktop.
Sync git to svn - commit history will NOT be kept. One way sync only.
#!/bin/sh
SVN_REPO=mydomain.com/svn-repo/trunk
GIT_REPO=SVN_REPO=mydomain.com/git-repo.git
# CLONE GIT
rm -rf git-downstream
git clone $GIT_REPO git-downstream --depth=1
# CLONE SVN
rm -rf svn-upstream
git svn clone $SVN_REPO svn-upstream
# CREATE PATCH FROM DIFF BETWEEN REPOS
diff -urN svn-upstream git-downstream -x .git -x .svn > sync.patch
cat sync.patch
# APPLY PATCH
cd svn-upstream
git apply ../sync.patch
git add .
git commit -m "git to svn sync"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment