Skip to content

Instantly share code, notes, and snippets.

@hydra1983
Last active August 29, 2015 14:03
Show Gist options
  • Save hydra1983/d98e0782627c123c7567 to your computer and use it in GitHub Desktop.
Save hydra1983/d98e0782627c123c7567 to your computer and use it in GitHub Desktop.
Merge changes from git to svn
# Fetch all commits
git fetch upstream master

# Find the commit id of last merge
git log

# Generate patches per commit
git format-patch -o <patches dir> <last merge commit id>

# Revert all to last merge commit
# The commit after last merge commit will be abandoned
git reset --hard <last merge commit id>

# Update svn repository
svn revert -R .
svn up

# Commit changes from svn to git
git add -A .
git commit -m "[SVN] Update to REV. <RevNum>"

# Apply patches one by one
git am <patch file path>

# If patch failed
# 1. Apply applicable parts or patch and generate .rej file
git apply --reject <patch file path>

# 2. Fix conflicts according to generated .rej file

# 3. Add all fixed files
git add -A . 

# 4. Resolve patch
git am --resolved

# Push changes to remote repository and discard all commits since last merge commit
git push --force
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment