Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Merging changes from a public repository into a private build

Tags:

git

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?

like image 670
stefan.at.wpf Avatar asked Aug 19 '20 16:08

stefan.at.wpf


People also ask

How do I change a public repository to private?

Under your repository name, click Settings. Under "Danger Zone", to the right of to "Change repository visibility", click Change visibility. Select a visibility. To verify that you're changing the correct repository's visibility, type the name of the repository you want to change the visibility of.

Can you have a private branch in a public repo?

You might as well want to merge every new commit on the public branch to your private branch. This situation happens mostly when you are creating a public repository but also want to use it for your private project. Sadly, GitHub did not allow a private branch on a public repository.

Can a public repo be made private GitHub?

You can now set your repository to any available visibility option – public, private, or internal – from a single dialog in the repository's settings.


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
like image 70
VonC Avatar answered Nov 07 '22 13:11

VonC