Skip to content

Instantly share code, notes, and snippets.

@katta
Created June 16, 2011 08:10
Show Gist options
  • Star 11 You must be signed in to star a gist
  • Fork 9 You must be signed in to fork a gist
  • Save katta/1028871 to your computer and use it in GitHub Desktop.
Save katta/1028871 to your computer and use it in GitHub Desktop.
Converts git diff to svn patch format
git diff --no-prefix | sed -e "s/^diff --git [^[:space:]]*/Index:/" -e "s/^index.*/===================================================================/" --ignore-space-at-eol > changes.patch
@r-a-y
Copy link

r-a-y commented Jul 20, 2011

Thanks! I took this code as a basis and created an alias.

@neosergio
Copy link

I updated my fork https://gist.github.com/neosergio/5979125 because the parameters cause an error on my diff

@geoff-nixon
Copy link

Awesome. @neosergio is right, you're passing --ignore-space-at-eol to sed here accidentally. I forked this here, added another bit of regex to trim off the context after @@ and to allow a bit more flexible usage: you can drop this one in your path and then call it will extra parameters (-U0 somefile, etc.).

@rambattu
Copy link

In case we already have a diff which got generated without "--no-prefix" option, here is a script git-diff-to-svn-path.sh that is inspired from this script gitdiff-svnpatch.sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment