如何将 "shadow" git 存储库与主存储库同步 "secretly"

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

我有一个客户,我通过 git 存储库为其工作。我不想让他知道我正在部分使用另一个开发人员。因此,我创建了一个 "shadow" 存储库,我的开发人员正在使用它。

如何将"shadow"仓库与主仓库同步,​​让主仓库不知道发生了什么?

有没有其他方法可以"secretly" 将文件内容从影子存储库复制到主存储库?是否有 linux/osx-command 我可以使用它来替换文件的内容而不删除和重新创建文件(然后我可以递归地使用它)?是否有一个 git-command 可以在不留下我实际所做的证据的情况下实现这一点?

您可以使用命令行让不同的 git 存储库修改同一组 local 文件。只需使用 GIT_DIR 环境变量。 Git 个存储库是完全独立的,可以跟踪同一目录中的文件。

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

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=/path/to/client/repository.com

rem bring main repository up to date
git commit -m"changes brought over from sub-developer"

rem push the updated code to the client repository
git push

这对其他开发实践很有用,例如版本控制实验室数据、本地开发实用程序、工作日志和其他 'misc' 似乎与源代码一起累积但不应与源代码一起存档的文件.

在第一次回答错误后,我觉得有必要再试一次。

尝试阅读子开发人员分支并 comparing/merging 到主分支 git 差异。 'diff.external' 参见 'git help config'。我使用 diffuse.exe 和一个批处理文件来映射参数。

工作流程看起来像这样。

rem make a remote to the sub
git remote add MYSUB https://path/to/sub/repository.com

rem see what branches are there
git remote show MYSUB

rem get the branch from the subdeveloper
git fetch MYSUB CurBranch:CurBranch

rem view/manually merge just the modified files 
git diff --diff-filter=M MYSUB/CurBranch 

rem cleanup
git branch -D MYSUB/CurBranch
git rm MYSUB

rem push to main site
git push

这是我通过 USB 记忆棒将分支传输到我的实验室机器的方法。我没有尝试过远程连接。