1 year ago

#280471

test-img

gehho

What's the best way to selectively share changes between two Git repositories?

We have a Git repository (in Azure DevOps) containing code for a library which is going to be refactored heavily in certain areas. However, some areas of the code will remain (almost) unchanged. As part of the changes, the library will get a new name. This is why we plan to create a new repository for these changes, so that the refactored library is clearly separated from the original library.

The refactoring will take some time, and during that time, we'll be forced to maintain the old version of the library and provide bugfixes and possibly new features. Since parts of the library will remain unchanged, we would like to be able to merge those bugfixes from the old repository to the new repository (and probably vice versa). However, we do not want to merge ALL changes, but only specific ones - kind of cherry-picks between two repositories. I know that this may not be possible forever since the two repositories will diverge more and more.

What's the best solution for such a scenario?

I have thought of the following solutions:

  1. Create a new repository, clone the old repository, change the remote of that clone to the new repository, and push everything to the new repository. Afterwards do the renaming and refactoring in the new repo, and do the bugfixing in the old repo. If a bugfix should be merged to the new repo, I would switch my working copy to the new repo, and cherry-pick the revision with the bugfix from the old repo by specifying the old repo as the remote.
  2. Create a fork of the old repo, perform the renaming and refactoring in the fork, and do the bugfixing in the original repo. A bugfix from the original repo could be merged to the fork using a pull request, and also vice versa if required. I am unsure if this approach would support the selective cherry-picking. I fear that I would only be able to merge ALL changes from original to fork which is not what I want.

As you can see, my experience with Git is limited and I would need some advice. Is one of the proposed options a viable solution, or is there a better way to approach this?

git

azure-devops

merge

repository

cherry-pick

0 Answers

Your Answer

Accepted video resources