Skip to content

Instantly share code, notes, and snippets.

@Girgias
Last active December 5, 2020 12:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Girgias/be1a31d2baa61ad763d5039289e232e2 to your computer and use it in GitHub Desktop.
Save Girgias/be1a31d2baa61ad763d5039289e232e2 to your computer and use it in GitHub Desktop.
How to commit a Git patch to SVN for the PHP Documentation

This assumes 2 copies of the PHP documentation repo, one "official" SVN which is meant to be kept clean, and a fork of php/doc-en

After the doc PR has been reviewed/approved/decided to merge, squash it into one commit (make sure the branch is up to date with upstream).

Assumed file structure

For the purpose of this tutorial, the following file structure is assumed:

|
|-- doc-en the Git fork
| |(content of English documentation)
|
|-- phpdoc-en (can be any language)
  | -- en

Before starting

Update the SVN repo by running svn update to prevent merge conflicts later down the line

Generating the patch

Use the following command git diff --no-prefix HEAD^ HEAD > patch-file.diff

Note: HEAD can be replaced by the commit hash.

Applying the patch

Move into the SVN repo under then en folder (or other language if working on a translation), i.e. cd ../phpdoc-en/en and execute the following command: patch -p0 < ../../doc-en/patch-file.diff

Note: files need to be deleted and added manually to SVN by using: svn add file and svn delete file as it is not supported by the patch command, it will show as a reject file.

Commiting back upstream

Double check the status by running svn status if happy use the follwing command: svn commit --include-externals -m "Commit message"

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