The best way to maintain a Git fork

ACME retains Product X, which we are expanding and customizing. They made their git repository visible to us, but we cannot write it. ACME uses its own internal git server with Gitolite.

Our developers want to write, so we need a local copy. However, it would be nice for me to keep the Commit history from ACME. Is there a way to do this? Also, how do I need to update my code with code from ACME? We are using Github Enterprise.

The way I thought is losing history from ACME.

  • Clone storage X to the Staging folder. Keep this repository up to date from ACME.
  • Create a new repository Y for our use.
  • Create a branch in repository Y for the "Original" code. Developers will separate or develop from this.
  • Manually copy files from repository X to the "Original" branch of repository Y.

There must be a better way. I essentially want to create a local fork and update it while still keeping our developers access to the commit code.

+3


source to share


2 answers


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

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



whenever ACME changes the code, you checkout the ACME vendor branch and store the updates there, tag with vendor tag (this makes it easier to see ACME versions in the house) and change the necessary changes.

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

+2


source


In my opinion you can fork the ACME repository. So now you have write access to your forked repository (or local clone).

You can now create a new branch in this local repository to continue your development while keeping the master branch (or renaming it to suit your needs) linked to the original readonly repository.



By doing this, whenever you need to update your code to the latest developments made in the ACME repository, you can simply fetch their changes from this remote and merge them into your development branch. There is no need to create multiple copies of this repository.

+1


source







All Articles