如何在sourcesup上将两个git存储库放入一个项目中 [英] How to put two git repository into one project on sourcesup

查看:74
本文介绍了如何在sourcesup上将两个git存储库放入一个项目中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我是在 INRAE 工作的硕士研究生.
尝试将不同的存储库克隆为一个时遇到问题:
我有一个 git 项目p1"
git 项目P2"
我想创建一个项目项目"在 sourceup 上,然后添加两个项目.
最后我想要一棵树这样
-项目
--------P1
--------P2

Hi every body I'm student in master degres I work at INRAE.
I have a problem when trying to clone different repositories into one :
I have a git project "p1"
git project "P2"
and I want to create a project "Project" on sourcesup and then add the two projects.
at the end I want to have a tree like this
-Project
--------P1
--------P2

我尝试了很多命令,但没有任何作用或给我我正在搜索的内容
我希望我能在您的帮助下找到解决方案
谢谢

I tried a lot of commands but nothings works or give me what I'm searching for
I hope I will finf a solution with your help
Thank you

推荐答案

GIT 有一个称为子模块的功能,您可以在其中在一个主存储库中拥有多个 git 存储库.然后,您可以独立于子项目克隆小型主项目.Mediawiki 使用这种方法将皮肤与主项目分开

GIT has a feature called submodules where you can have multiple git repositories inside a main repository. You can then clone the small main project independently from the sub projects. Mediawiki uses this approach to separate skins from the main project

https://git-scm.com/book/en/v2/Git-Tools-Submodules

当你克隆主项目时,子模块将为空,除了 .git/config 允许你在主存储库之后更新子模块

The submodule will be empty when you clone the main project, except for the .git/config which allows you to update the submodule after the main repository

git submodule update --init

您可以使用 recurse-submodules 标志将子模块与主项目一起克隆

You can clone the submodules together with the main project with the recurse-submodules flag

git clone --recurse-submodules https://github.com/chaconinc/MainProject

如果您不想拥有独立的 git 存储库而是合并两个项目,则可以在需要标志 --allow-unrelated-history 的地方使用 git merge 以允许它们具有独立的历史记录.

If you don't want to have independent git repositories but merge the two project, you can use git merge where you need the flag --allow-unrelated-histories to allow them to have independent histories.

https://git-scm.com/docs/git-merge

这篇关于如何在sourcesup上将两个git存储库放入一个项目中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆