简体   繁体   English

GitHub(Git)与两个仓库一起工作

[英]GitHub (Git) Working with two Repo's

I have a Repo called "MVP" which contains code that I want to split out since it will be common to other parts of the system. 我有一个称为“ MVP”的存储库,其中包含我想拆分的代码,因为它对于系统的其他部分是通用的。 I created a new Repo called "shared" with no history, I used Git Archive see here 我创建了一个名为“共享”的新回购,没有历史,我用的Git档案这里

I then git remote add mvp and git remote add shared in the same directory. 然后我将git remote add mvpgit remote add共享在同一目录中。

I pull the mvp and was hoping I could simply pull the shared too, however, git wants to do a merge. 我拉了MVP ,并希望我也可以简单地拉共享 ,但是,git想做一个合并。 Which is not what I want. 这不是我想要的。

Can anyone suggest a strategy that might work for my requirement to have a repo containing a shared code base and be able to pull that code base in-place within another local repo ? 谁能建议一种策略,该策略可能适合我的需求,即拥有一个包含共享代码库的存储库,并能够将该代码库放在另一个本地存储库中就位?

EDIT: 编辑:

Not sure if this is the best approach: 不知道这是否是最好的方法:

1. Create shared code repo
2. Create other repos for projects
3. Deploy projects (git pull) 
4. Depoly shared repo (git pull)
5. Create Symbolic link from projects to shared repo
6. add symbolic link to .gitignore

A git pull is a git fetch followed by a git merge, so you actually asked git to do a merge. git pull是git fetch,之后是git merge,因此您实际上要求git进行合并。

I suspect that you however want to use a submodule or subtree for your usecase. 但我怀疑您想为您的用例使用子模块或子树。 That will allow you to have a git repo inside an other git repo. 那将允许您在另一个git repo内有一个git repo。 You should read about this in the git book. 您应该在git书中阅读有关此内容的信息。

For your case I should try something like: 对于您的情况,我应该尝试类似的方法:

git clone ssh://example.com/mvp
git submodule add ssh://example.com/shared shared
git submodule update

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM