Git:从现有的存储库创建Git子模块,并将父级更改反映到子存储库 [英] Git: Creating Git Submodules out of existing repository and reflecting parent changes to the child repository

查看:128
本文介绍了Git:从现有的存储库创建Git子模块,并将父级更改反映到子存储库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请注意,我是Git的新手。

Please note that I am new to Git.

我有两个回购:

I have two repos:


  1. Libgdx REPO

  2. gdx-sqlite REPO

  1. Libgdx REPO
  2. gdx-sqlite REPO

主要的存储库是Libgdx REPO,我所有的工作都进入了这个仓库,主要在 gdx-sqlite项目。因为我希望gdx-sqlite项目作为单独的存储库出现,所以我做的是:
$ b

The main repository is Libgdx REPO and all of my work goes into this repository, mainly in the gdx-sqlite project. Since I wanted gdx-sqlite project to appear as a separate repository, what I did was:


  1. 在GitHub上创建了一个新的回购(gdx- sqlite REPO)
  2. 在我的机器上创建一个本地repo(嵌套在本地libgdx repo中)
  3. 将本地嵌套repo的所有代码远程gdx-sqlite REPO

这导致一切都出错,我认为嵌套仓库是主要的罪魁祸首。后来我删除了本地嵌套的存储库,并恢复到之前的提交。我发现这种问题的解决方案是Git Submodules,但我完全失去了我想要实现的内容,如下所示。

This resulted in everything going wrong and I assumed that nested repository was the main culprit. Later I deleted the local nested repository and reverted to a previous commit. I have found out that a solution to this kind of problem is Git Submodules but I am completely lost at what I am trying to achieve which is as follows.

现在怎么样我应该根据以下内容来实现这一点:

Now how am I supposed to achieve this in light of the following:


  1. 我想创建一个位于gdx-sqlite REPO 应始终反映我对位于 https://github.com/mrafayaleem/libgdx/tree/master/extensions/gdx-sqlite

  2. 任何发送将请求拉到gdx-sqlite REPO应该能够拉出所有依赖项(即完整的libgdx REPO),以便他可以立即使用该扩展名。

  1. I want to create a new repo located at "gdx-sqlite REPO" that should always reflect the changes I make to the project located at "https://github.com/mrafayaleem/libgdx/tree/master/extensions/gdx-sqlite"
  2. Anyone who sends a Pull Request to "gdx-sqlite REPO" should be able to pull all the dependencies (that is the complete libgdx REPO) so that he can work on that extension right away.

这怎么能成为possbile?

How can this be made possbile?

推荐答案

再右吧。这种情况的好方法是使用 Git子模块。这是处理Git中依赖关系的最好方法。

You're right. The good approach for this kind of situation is to use Git submodules. This is the best way to handle dependencies in Git.

正如 gdx-sqlite 是您的主项目 Libgdx 的扩展,您可以通过这种方式将其添加为子模块: p>

As gdx-sqlite is an extension of your main project Libgdx, you could do it this way to add it as a submodule:

git clone git@github.com:mrafayaleem/libgdx.git libgdx
cd libgdx
# remove the old directory
rm -rf extensions/gdx-sqlite
git add extensions/gdx-sqlite
# add the submodule (note the read-only URL)
git submodule add git://github.com:mrafayaleem/gdx-sqlite.git extensions/gdx-sqlite
# commit the changes
git commit -m 'Add submodule for the gdx-sqlite extension'

然后克隆您的项目(及其所有子模块):

Then to clone your project (and all its submodules):

git clone --recursive git://github.com/mrafayaleem/libgdx.git

或者对于你(有写权限):

Or for you (with write access):

git clone --recursive git@github.com:mrafayaleem/libgdx.git

这篇关于Git:从现有的存储库创建Git子模块,并将父级更改反映到子存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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