Git:如何处理项目中的git库 [英] Git: How to handle git libraries in project

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

问题描述

我有一个自己拥有Git Source Control的Xcode项目。在 Libraries 文件夹中,我从 GitHub 克隆了其他八个Git项目。它们位于我自己的Git仓库中,我已经将所有这些库添加到了我的git中。

I've a Xcode project which itself has Git Source Control. In a Libraries folder I've cloned eight other Git project from GitHub. They are located inside my own Git repository and I've added all these libraries to my git in a commit.

不是将所有这些git库的代码放在我的仓库,有没有办法让git在我的repo克隆时从他们的repo下载他们的代码?或者在项目中包含其他git repos是否正常?

Instead of having the code of all these git libraries in my repository, is there a way to let git download their code from their repo when I make a clone of my repo? Or is it normal to include other git repos inside a project?

推荐答案

确保执行以下操作:

Sure do the following:


  1. 删除您可能已添加的第三方文件夹

  2. 打开终端并执行以下命令

  1. Remove the 3rd-party-folder which you might have added already
  2. Open your Terminal and execute the following commands

cd /path/to/your/main/repo
git submodule add git@github.com:someuser/somerepo.git somerepo
git commit -m "Added submodules"


  • 现在改为复制这些文件,你将会在项目中引用另一个存储库:

  • Now instead of copying those files you'll have a reference to the other repository in your project:

    http://i.minus.com/jcphKnFxLexk8.png

    编辑:

    现在,如果您想将子模块更新为更新的提交,您可以执行以下操作:

    Now if you want to update the submodule to a more recent commit you can do the following:

    cd somerepo
    git pull # You can also checkout a branch / tag etc.
    cd ..
    git add somerepo
    git commit -m "Telling the main repo to update the reference to the referenced repo"
    

    这篇关于Git:如何处理项目中的git库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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