git submodule 使用过程中遇到的问题

资源文件

  • 原.gitmodules文件的内容如下:

      [submodule "Submodules/FFmpegWrapper"]
    path = Submodules/FFmpegWrapper
    url = git@github.com:OpenWatch/FFmpegWrapper.git
    [submodule "Submodules/CocoaHTTPServer"]
    path = Submodules/CocoaHTTPServer
    url = git@github.com:robbiehanson/CocoaHTTPServer.git
    [submodule "Submodules/OWS3Client"]
    path = Submodules/OWS3Client
    url = git@github.com:OpenWatch/OWS3Client.git
    [submodule "Submodules/SSKeychain"]
    path = Submodules/SSKeychain
    url = git@github.com:soffes/sskeychain.git
    [submodule "Submodules/CocoaLumberjack"]
    path = Submodules/CocoaLumberjack
    url = git@github.com:CocoaLumberjack/CocoaLumberjack.git
    [submodule "Submodules/AFNetworking"]
    path = Submodules/AFNetworking
    url = git@github.com:AFNetworking/AFNetworking.git
    [submodule "Submodules/AFOAuth2Client"]
    path = Submodules/AFOAuth2Client
    url = git@github.com:AFNetworking/AFOAuth2Client.git

步骤

  • 1、首先我们clone一下目标工程,然后进入工程目录

    git submodule init

      Submodule 'Submodules/AFNetworking' (git@github.com:AFNetworking/AFNetworking.git) registered for path 'Submodules/AFNetworking'
    Submodule 'Submodules/AFOAuth2Client' (git@github.com:AFNetworking/AFOAuth2Client.git) registered for path 'Submodules/AFOAuth2Client'
    Submodule 'Submodules/CocoaHTTPServer' (git@github.com:robbiehanson/CocoaHTTPServer.git) registered for path 'Submodules/CocoaHTTPServer'
    Submodule 'Submodules/CocoaLumberjack' (git@github.com:CocoaLumberjack/CocoaLumberjack.git) registered for path 'Submodules/CocoaLumberjack'
    Submodule 'Submodules/FFmpegWrapper' (git@github.com:OpenWatch/FFmpegWrapper.git) registered for path 'Submodules/FFmpegWrapper'
    Submodule 'Submodules/OWS3Client' (git@github.com:OpenWatch/OWS3Client.git) registered for path 'Submodules/OWS3Client'
    Submodule 'Submodules/SSKeychain' (git@github.com:soffes/sskeychain.git) registered for path 'Submodules/SSKeychain'
  • 2、接下来我们尝试更新子模块

    git submodule update --init --recursive

      $ git submodule update --init --recursive
    Cloning into '/Users/macmini_35/Downloads/FFmpeg-iOS-Encoder/Submodules/AFNetworking'...
    Permission denied (publickey).
    fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.
    fatal: clone of 'git@github.com:AFNetworking/AFNetworking.git' into submodule path 'filepath/FFmpeg-iOS-Encoder/Submodules/AFNetworking' failed
    • 1、问题出现了无法更新(提示:没有权限,不能读取远程库)

      • 这个错误原因按照提示的原因,应该是SSH的问题,解决办法,这里我就不说怎么做了,怎么操作请自行Google

        这只是一个小问题,如果按照正常思路就不会遇见下一个问题了,我选择一种解决方法,

        删除子模块,重新添加子模块(资源链接换成https的)。
  • 3、删除子模块,重新添加子模块

    • 1、由于平常用到的git命令很少,于是乎我去查了一下命令(不截图了)

        Fails with error: 'fatal: Please, stage your changes to .gitmodules or stash them to proceed'
      
        This appears to be rather outdated. The current correct procedure:
      
        git submodule deinit <name>
      git rm --cached <name>
      rm -rf .git/modules/<name>
      From: http://stackoverflow.com/questions/1260748/how-do-i-remove-a-git-submodule

      这个结果在github上边找到的,然后根据后边的链接跳到了stackoverflow,这里只有一部分请自行前往浏览完整篇;

        There was no Porcelain way to say "I no longer am interested in this submodule",once you express your interest in a submodule with "submodule init".
      "submodule deinit" is the way to do so.
      The deletion process also uses git rm (since git1.8.5 October 2013). Summary The all removal process would then be: mv asubmodule asubmodule_tmp
      git submodule deinit asubmodule
      git rm asubmodule

# Note: asubmodule (no trailing slash)

# or, if you want to leave it in your working tree

		git rm --cached asubmodule
mv asubmodule_tmp asubmodule
But you seem to still need a: rm -rf .git/modules/asubmodule

嗯!开始尝试

		*$ git submodule deinit Submodules/AFNetworking
Submodule 'Submodules/AFNetworking' (git@github.com:AFNetworking/AFNetworking.git) unregistered for path 'Submodules/AFNetworking'
*$ git rm Submodules/AFNetworking
rm 'Submodules/AFNetworking'
*$ git rm --cached Submodules/AFNetworking
fatal: pathspec 'Submodules/AFNetworking' did not match any files
*$ git submodule add https://github.com/AFNetworking/AFNetworking.git Submodules/AFNetworking
Cloning into '/Users/macmini_35/Downloads/FFmpeg-iOS-Encoder/Submodules/AFNetworking'...
remote: Counting objects: 14512, done.
remote: Total 14512 (delta 7), reused 7 (delta 7), pack-reused 14504
Receiving objects: 100% (14512/14512), 5.17 MiB | 1.83 MiB/s, done.
Resolving deltas: 100% (9552/9552), done.
Checking connectivity... done.

备注:

**请一定要按照顺序操作啊!本来都已经完事了,就是因为顺序错了搞得有重来了一次**

  • git submodule deinit submodulename
  • git rm submodulename
  • git rm --cached submodulename
  • rm -rf ./git/modules/submodulename 这一步是针对已经update之后的子模块删除的

git submodule 使用过程中遇到的问题的更多相关文章

  1. gitlab使用过程中的需求与解决

    序言 在git使用过程中发现指令实在太多,就算记忆后不长用的话很快也会忘记掉,所以编写本文的初衷是为了记录在使用git指令的过程中所遇到的需求与解决方法,毕竟使用git的需求也就那么一些,范围不大,所 ...

  2. 开发与测试整体过程中的Git分支merge流程

    开发与测试整体过程中的Git分支merge流程 Git分支merge之开发流程 首先在Gitlab上有个仓库存储着原始的项目代码,其中包含一个叫master的分支.然后可能按功能进行分配,由不同的开发 ...

  3. Git使用过程中出现项目文件无法签入Source Control的情况

    在VS中使用Git进行项目source control的过程中,有些文件不在source control之下,右键点击时,也找不到Undo, Commit命令 无法把他们签入进Source Contr ...

  4. [Git]07 如何在提交过程中忽略某些文件

     一般我们总会有些文件无需纳入 Git 的管理,也不希望它们总出现在未跟踪文件列表.通常都是些自动生成的文件,比如日志文件,或者编译过程中创建的临时文件等.我们可以创建一个名为 .gitignor ...

  5. Git submodule 仓库中包含另外的仓库(子仓库)

    Git submodule 仓库中包含另外的仓库(子仓库) 添加 submodule 在父仓库 git 目录下: git submodule add ssh://ip/[path]/xxx.git 注 ...

  6. git rebase 过程中遇到冲突该怎么解决?

    在执行git rebase 过程中经常遇到问题,此时有点慌,一般如何解决呢? 1.先将本地的冲突手动解决 2.执行下面命令 git add . git rebase --contine  //继续re ...

  7. git提交过程中遇到的 index.lock 问题导致无法提交的解决方法

    在提交代码的过程中,可能会遇到下面的问题: fatal: Unable to create 'C:/programLists/zzw-q1/.git/index.lock': File exists. ...

  8. 在SourceTree中使用Git submodule

    在開發的過程中我們的項目可能會引用其他的版本庫中的代碼, 例如公司已經累積了一套公用的函式庫, 被多個項目調用;  很顯然地, 不能把公用函式庫的文件直接放到我們開發中的項目中, 這樣不但項目的冗餘, ...

  9. git submodule初用

    git submodule主要是用于针对git项目中还存在git子模块的情况.在一般情况下,我们通过git clone 获取项目的时候会把项目中的所有信息都拿到.但是,如果相关中存在git子模块那么, ...

随机推荐

  1. Dubbo源码学习文章目录

    目录 Dubbo源码学习--服务是如何发布的 Dubbo源码学习--服务是如何引用的 Dubbo源码学习--注册中心分析 Dubbo源码学习--集群负载均衡算法的实现

  2. 最新升级的火狐38.0.6识别ajax调用返回的""空值可能有异常。

    自已在调用一段ajax开发中,返回的是空值 string result = string.Empty;return result; 但在页面进行$.ajax调用 时 输出alert(result);应 ...

  3. iOS 设置#ffff 这种颜色

    UI给图的时候给的是#f2f2f2 让我设置.没有你要的rgb. 所以只能自行解决封装了代码 HexColors.h #import "TargetConditionals.h" ...

  4. 读书笔记 effective c++ Item 2 尽量使用const,枚举(enums),内联(inlines),不要使用宏定义(define)

    这个条目叫做,尽量使用编译器而不要使用预处理器更好.#define并没有当作语言本身的一部分. 例如下面的例子: #define ASPECT_RATIO 1.653 符号名称永远不会被编译器看到.它 ...

  5. j2se 总结

    j2se在学习第二遍的时候,感觉还是比较亲切的.

  6. 网络请求 ---iOS

    //1.url要访问的资源 NSURL *url = [NSURL URLWithString:@"http://www.baidu.com"]; //2.请求,要向服务器请求 N ...

  7. Dynamics CRM 2015-Form之控制Ribbon Button

    在上一篇中,我用一个例子,简单介绍了如何添加Ribbon Button,以及如何理解RibbonDiffXml,对这方面还不清楚的,可以先看看这篇博文:Dynamics CRM 2015-Form之添 ...

  8. iOS UISearchController 的使用方法

    iOS UISearchController 的使用方法 UISearchController 让用户在 UISearchBar 上输入搜索关键词,展示搜索结果或者进行其他操作.UISearchCon ...

  9. C#中字符和字符串总结

    Char类是C#提供的字符类型,String是C#提供的字符串类型. 字符: Char类在C#中表示一个Unicode字符. Char类只定义一个Unicode字符. Char类常用的方法及说明如下: ...

  10. 今天遇到的面试题for(j=0,i=0;j<6,i<10;j++,i++) { k=i+j; } k 值最后是多少?

    for(j=0,i=0;j<6,i<10;j++,i++) { k=i+j; } k 值最后是多少? <script type="text/javascript" ...