BRabbit27
BRabbit27

Reputation: 6623

Is it possible to communicate two local git-repos?

I got a very strange scenario today at work involving git repos. The idea is to have two repositories with the following constrains

local-RepoA

  1. has all my source code, say, ShareOk.cpp and ShareNok.cpp
  2. pushes to http://remote-RepoA.git

local-RepoB

  1. should only have those files from RepoA which are fine to share with other people, in this case only ShareOk.cpp
  2. before pushing changes to remote, needs to do some code cleaning
  3. pushes to http://remote-RepoB.git

Is there a way to "push" certain files from local-RepoA to local-RepoB to do code cleaning and then push the changes to remote-RepoB ?

This does not make sense to me, but I was asked to check for some way to link the two local repos.

EDIT

From the answer provided below, I think my description was not complete so I will extend it further

There are two developement groups.

Group A possess all the source code and work only in repoA whose upstream is set to http://repoA.git. All the source code could be messy and with untested code.

Group A wants to give Group B the code up to a certain point/commit from repoA that is known to be working flawlessly, with clean and tested code. So Group A wants to have a way to put into repoB with upstream http://repoB.git this code preserving the history of changes for the files being shared with Group B.

Finally Group B just clones/pulls from http://repoB.git and check the code compiles and runs and then they do some other stuff with it.

Upvotes: 2

Views: 829

Answers (2)

Useless
Useless

Reputation: 67723

Group A wants to give Group B the code up to a certain point/commit from repoA that is known to be working flawlessly, with clean and tested code. So Group A wants to have a way to put into repoB with upstream http://repoB.git this code preserving the history of changes for the files being shared with Group B.

It sounds like repoB should be a bare clone of repoA. Then you just need to manage the process of pulling B from A.

Assuming some release branch, or a tag indicating what commit in A is the "known good" point B should follow, you just need to run git pull KnownGoodPoint:master while in the repoB directory.

This also assumes no-one in group B is pushing back to repoB, so you should disallow that.

Upvotes: 1

Rick
Rick

Reputation: 411

I doubt that pushing commits/files from one repo to another is really what you want. From the provided context I cannot decide if this would apply, but generally I would recommend to have Repo B be your upstream (main) repo and work on that (publicly), like you would do with any package or module you want to share.

In RepoA you can setup RepoB as a dependency, and apply any customizations or modifications by extending RepoB, while only committing overrides in RepoA.

This would also prevent you having to 'censor' files or commits you want to push publicly.

Upvotes: 1

Related Questions