Merging changes from a public repository into a private build

Viewed 100

Assume I clone a repository OSS at version 1.0 containing a class A. Subclassing A is not enough for me, so I copy A to A' and make some modifications to it. At a later point in time, I clone OSS at version 1.1, containing an updated version of A. How can I merge the changes/updates from A to my modified copy A'? Is there a standard pattern for such cases?

1 Answers

The idea is to:

  • create the patch using git diff: between A#1.0 and 1#1.0

    git diff 1.0 1.1 -- A > a.patch
    
  • then apply that patch using the patch utility: you can specify the file you want to apply the diff to with patch.

    patch -p1 A' a.patch
    

On Windows, use a simplified PATH as in here, and you will see patch available:

C:\git\>where patch
C:\prgs\gits\current\usr\bin\patch.exe
Related