指向多个 git 个存储库的单个目录

Single directory pointing to multiple git repositories

我在软件供应商公司工作。我的团队需要将代码提交到客户的 git 存储库,我们在提交代码之前进行代码审查,我们将在其中获得所有评论和代码 correction.To 设置此流程, 我想将父项目目录指向多个 git 存储库

如何在 osx 上的同一目录中设置两个 git 存储库。我正在使用 sourcetree 作为 git 工具

您可以设置多个推送 URL 到一个远程。

来源是 git 项目中的默认远程:

git remote -v
origin  git@git.company.es:group1/project.git (fetch)
origin  git@git.company.es:group1/project.git (push)

然后你可以添加更多推送 url 到你的遥控器。

git remote set-url --add --push origin git@git.other.es:test/project.git

现在您应该显示两个(推送)URL 和一个(获取)URL。是这样的: git 远程-v 原点 git@git.company.es:group1/project.git(获取) 来源 git@git.company.es:group1/project.git(推) 原点 git@git@git.other.es:test/project.git(推送)

推送到这个远程会同时推送到两个上游。从此远程获取和拉取仍将仅从原始存储库中拉取。

您也可以保留原始远程(origin)并创建一个替代远程并使用它来推送两个存储库:

git remote add both
git remote set-url --add --push both 
git@git.company.es:group_1/project.git
git remote set-url --add --push both git@git.other.es:test/project.git

您的远程配置将是:

git remote -v
origin  git@git.company.es:group1/project.git (fetch)
origin  git@git.company.es:group1/project.git (push)
both    git@git.company.es:group1/project.git (fetch)
both    git@git.company.es:group1/project.git (push)
both    git@git@git.other.es:test/project.git (push)

现在您可以决定在不同情况下要使用哪个遥控器。