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. php面向对象(OOP)---- 验证码类

    PHP常用自封装类--验证码类 验证码是众多网站登陆.注册等相关功能不可以或缺的功能,实现展示验证码的方式有很多,这篇文章作者以工作中比较常用的方法进行了封装. 逻辑准备 要实现一个完整的验证码,需要 ...

  2. sessionstorage,localstorage和cookie之间的区别以及各自的用法

    由于年前辞了自己的工作,年后又开始重新找工作,参加了好几次面试,居然都遇到了同样的面试题:sessionstorage,localstorage和cookie之间的是区别? 当然,在面试的时候答的也不 ...

  3. ICMP(网际控制报文协议)

    为了更有效的提高ip数据报的成功转发和交付的效率,在网际层使用了icmp网际控制报文协议,这个协议允许主机和路由器提供差错和异常情况的报告,icmp不是高层协议,而是网际层的协议,加在ip数据报中一起 ...

  4. 读书笔记 effective c++ Item 14 对资源管理类的拷贝行为要谨慎

    1. 自己实现一个资源管理类 Item 13中介绍了 “资源获取之时也是初始化之时(RAII)”的概念,这个概念被当作资源管理类的“脊柱“,也描述了auto_ptr和tr1::shared_ptr是如 ...

  5. RAID分类

    1. RAID在数据库存储上的应用   随着单块磁盘在数据安全.性能.容量上呈现出的局限,磁盘阵列(Redundant Arrays of Inexpensive/Independent Disks, ...

  6. 漂亮的代码3:flatten 一个数组

    看到一个题目: flatten([1,2,3]) // => [1,2,3] flatten([[1,2,3],["a","b","c" ...

  7. Dijkstra算法的二叉堆优化

    Dijkstra算法的二叉堆优化 算法原理 每次扩展一个距离最小的点,再更新与其相邻的点的距离. 如何寻找距离最小的点 普通的Dijkstra算法的思路是直接For i: 1 to n 优化方案是建一 ...

  8. javascript组成概述认识

    这里的JavaScript组成概述是说的在浏览器端渲染的JavaScript而不是nodejs js组成概述 js的完整实现是由ECMAscript.DOM.BOM三个部分组成的: -ECMAscri ...

  9. Vue2.0音乐播放器

    学习了几周的vuejs,学习的过程中做了一个音乐播放器WebApp (顺便听听音乐~) ,过程中也有借鉴过别人做的,感觉受益匪浅 链接 项目在线地址 : 音乐播放器 github : https:// ...

  10. Vue开源项目库汇总

    最近做了一个Vue开源项目库汇总,里面集合了OpenDigg 上的优质的Vue开源项目库,方便移动开发人员便捷的找到自己需要的项目工具等,感兴趣的可以到GitHub上给个star. UI组件 elem ...