Home > Blockchain >  Git new way of maintain two repositories which shares same files
Git new way of maintain two repositories which shares same files

Time:08-24

Let's say there are two git repositories living independently:

repo_A structure

repo_A
├── dependencies
│   └── from_repo_B
│       └── script_B
└── other_stuff_A
    ├── script_1
    └── script_2

repo_B structure

repo_B
├── common
│   └── script_B
└── other_stuff_B
    ├── script_4
    └── srcipt_3

Repo_A scripts have to use files inside common folder from repo_B. They are manually copied to from_repo_B folder about once a month or after significant changes made on repo_B side (let's call it release process). Scripts in Repo_B/other_stuff_B folder are also using script_B code. There is a bottleneck which is review and merge time for repo_A. This time for repo_B is significantly shorter.

Sometimes there is need to quick fix script_B code directly on repo_A. In this case there are two pull requests on each repository created.

Changing script_B file on repo_B can broke script_1 and script_2 during the release process. Changes solving these problems are made on repo_B then release process is repeated.

Can someone see more clever way of maintain these repositories? I was thinking about Google repo tool but developers who are working only on repo_A and are not touching script_B file will not be pleased with the new way of preparing repository for development (repo sync etc.). Maybe git subtree? Git submodule? Something else?

CodePudding user response:

Asked (and answered) even here a lot of times:

Use Git subtree

  • Restructure your repos and move shared trees of code into separate additional new repos
  • Add repos from the above into target repos with subtree's "magic"
  • Use repos in the usual way
  •  Tags:  
  • git
  • Related