Git and cloning

I made a client application called "A" (not really).

I found out that it is very cool and that I want to sell it to other clients as well. Directory "A" is the Git repository. I think I have a cloning problem. As far as I can see, I need to make a copy of the "A" directory and name it "Generic_A". Then remove dir 'A' and run "git clone Generic_A A". Then I could start modifying the "Generic_A" repo with a generic design and removing all client references. But this is quite the opposite. I had to start doing a generic design and then cloned the repo to redesign the client.

Can I:

  • create a new branch
  • make all changes to make the overall design
  • create a patch that reflects the changes between the two
  • delete client specific branch
  • rename the directory to "Generic_A"
  • clone repo to new directory 'A'
  • apply the patch to get the client stuff back.

And if so, how to make a patch and apply it?

Hello,

Jacob

+2


a source to share


2 answers


It might work, though between 6. and 7. I would make the client_A branch before applying the patch. The downside is that you lose the specificity of the commit history for client A, since you are applying this patch in one big commit.

In your case the patch can be done with , see the fix with git diff git diff

git diff --no-prefix > patchfile

      

then apply the patch:



patch -p0 < patchfile

      

If you have a " git diff

" patch file that was created without the "-no-prefix" option, you can apply this patch via:

patch -p1 < patchfile

      

this will ignore the a / b / source prefixes by default.

0


a source


A workflow is possible here:

  • On disk:
    • Create a new branch "generic" from the "client-A" branch.
    • Use 'git rebase -i' on 'Generic' to remove all client A components.
    • Use 'git rebase client-Generic' to restore your client. Forking on the general.
  • Rename directory A to shared directory
  • clone your generic directory to the new client directory
  • remove the client-A branch from the shared directory.


This way you will keep the history of the client-A branch.

+1


a source







All Articles