Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best way to maintain a Git fork

Company ACME keeps a product X that we extend and customize. They have made their git repository visible to us, but we can't write to it. ACME is using their own internal Git server with Gitolite.

Our developers want to write to it, so we need a local copy. However, I'd be nice to keep the Commit history from Company ACME. Is there a way to do it? Also, how should I go about updating our code with code from Company ACME? We are using Github Enterprise.

The way I was thinking loses the history from Company ACME.

  1. Clone repository X into a Staging folder. Keep this repository up to date from Company ACME.
  2. Create new repository Y for our use.
  3. Create branch in Repository Y for "Original" code. Developers would branch or fork from this.
  4. Manually copy the files from Repository X into "Original" branch of Repository Y.

There must be a best way. I essentially want to make a local fork and keep it updated while still giving our developers access to commit code.

like image 807
RommelTJ Avatar asked Oct 01 '22 01:10

RommelTJ


1 Answers

this is called the "vendor branch" pattern. (consider adding those SO tags to your post.)

you can also embed the ACME artefacts in your rep: the original, unchanged ACME code will live on its own (so-called "vendor"-) branch, and will be merged to 'master' or wherever you need it.

whenever ACME changes code, you checkout the ACME vendor branch and store the updates there, tag with the vendor tag (this eases seeing what versions of ACME are in house), and merge the changes where needed.

Edit added: Once you understand this mechanism, take a look at the subtree merge mechanism.

like image 117
axd Avatar answered Oct 03 '22 01:10

axd