git git合并不同的存储库?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2949738/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 08:29:23  来源:igfitidea点击:

git merge different repositories?

gitgit-svn

提问by baloo

I've been using SVN for all my projects. Sometimes project B is originating as a copy from project A. When project A has a generic change, I can use svn merge Awithin directory B and it will merge those changes.

我一直在为我所有的项目使用 SVN。有时项目 B 源自项目 A 的副本。当项目 A 有通用更改时,我可以svn merge A在目录 B 中使用,它将合并这些更改。

Now, if I wanted to use git. I don't like having all my projects in the same repository since I then have to clone everythingand can't pick just one project like in SVN. But having one repository for each project, how do I go about doing the same like I did earlier with SVN?

现在,如果我想使用 git。我不喜欢将我的所有项目都放在同一个存储库中,因为我必须克隆所有内容并且不能像在 SVN 中一样只选择一个项目。但是对于每个项目都有一个存储库,我该如何像之前使用 SVN 所做的那样去做呢?

The question is:What's the best way to structure it if I want several subprojects that really all relates to one original project and to keep them in sync? And that I also want to be able to check them out separately

问题是:如果我想要几个真正都与一个原始项目相关的子项目并使它们保持同步,那么构建它的最佳方法什么?而且我也希望能够分别检查它们

回答by Olivier Verdier

If you have two projects, proj1and proj2and want to merge changes of proj1into proj2, you would do it like this:

如果您有两个项目,proj1并且proj2想要将 的更改合并proj1到 中proj2,您可以这样做:

# in proj2:
git remote add proj1 path/to/proj1
git fetch proj1
git merge proj1/master # or whichever branch you want to merge

I believe this does the same thing as what you were doing with SVN.

我相信这与您使用 SVN 所做的相同。