EricC EricC - 1 year ago 67
Linux Question

how to sync a "shadow" git repository with a main repository "secretly"

I have a client that I do work for via a git repository. I do not want for him to know that I am partly using another developer. I have therefore created a "shadow" repository, that my developer is using.

How to sync the "shadow" repository with the main repository so that the main repository does not know that this is happening?

  • I cannot merge with a git command, since this will reveal what I really have done.

  • I could copy and paste all files, but that would visible in git that I have deleted all files and replaced with new files with the same name. That does not look good.

  • My client is using bitbucket. I could give the other developer my bitbucket login, but I would want to avoid to do that.

  • What actually work, is that I can open a file in the main repository, delete the content and then paste in the updated code. Then I could commit and it would look is if I had done the work directly in the main repository. But this is time-consuming (and time is something I do not have too much of).

Is there a different way that I could "secretly" copy the content of files from the shadow repository to the main repository? Is there a linux/osx-command I could use that replaces the content of a file without deleting and recreating the file (which I then could use recursively)? Is there a git-command that make this possible without leaving a trail of evidence of what I have actually done?

Answer Source

you can have the same set of local files revisioned by different git repositories, using the command line. Just use the GIT_DIR environment variable. The Git repositories are completely independent, and can track files from the same directory.

rem set Git to use the sub-developer's git repository
set GIT_DIR=http://path/to/sub/

rem verify which repository that you are on
git rev-parse --git-dir

rem pull the sub-developer's latest
git pull

rem merge, commit, change, push, change branches, whatever
rem ... when the code is the way you want it

rem switch to client repository
set GIT_DIR=http://path/to/client/

rem push the updated code to the client repository
git push

this is useful for other development practices, like versioning lab data, local developmental utilities, work logs, and other 'misc' files that seem to accumulate with the source code, but shouldn't be archived with it.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download