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. HTML__post 和 get区别【URL】

    一.get和post的区别: 表单提交中get和post方式的区别有5点 1.get是从服务器上获取数据,post是向服务器传送数据. 2.get是把参数数据队列加到提交表单的ACTION属性所指的U ...

  2. list_删除元素

    项目遇到了题目所述的问题,还是折腾了一会... 现在总结一下: 这里写一个测试小程序: List<Integer> ints = new ArrayList<Integer>( ...

  3. 网易云直播SDK使用总结

    前言: 最近公司的项目中加入中直播这部分的功能,现在的直播平台真的很多很多,以前在朋友圈看到过这张图片,没办法一次性给大家看,就只能这样截成几张给大家看看.其实按照我自己的看法,现在的直播已经没办法做 ...

  4. JSON - 使用cJSON 解析Qt通过UDP发送的JSON数据

    1,cJSON支持在C程序中创建和解析JSON数据,其提供多种方法供C程序使用,最直接的是将cJSON.c和cJSON.h加入到C工程中,源代码:https://github.com/DaveGamb ...

  5. BZOJ 3402: [Usaco2009 Open]Hide and Seek 捉迷藏(最短路)

    这个= =一看就是最短路了= = PS:最近有点懒 = = 刚才看到一道平衡树的裸题还嫌懒不去写= =算了等刷完这堆水题再去理= = CODE: #include<cstdio>#incl ...

  6. android学习1——LinearLayout

    用linearLayout,上面放4个按钮,不作任何设置.xml文件内容如下: <?xml version="1.0" encoding="utf-8"? ...

  7. WP8.1开发中对于XAML中一些语言的学习(1);

    以前在学习WP开发的时候,看到视频中说到程序在创建之初,MainPaige.xaml页面上有一些代码: <Page x:Class="草案.MainPage" xmlns=& ...

  8. Github网站加载不完全,响应超时,如何解决

    Github是一个代码托管平台和开发者社区,开发者可以在Github上创建自己的开源项目并与其他开发者协作编码.毫不夸张地说,高效利用Github是一个优秀的程序员必备的基本素质.可是,有的用户在打开 ...

  9. Chosen通用初始化

    一直在用Chosen这个js插件,其目的就是美化下拉框.github地址:https://harvesthq.github.io/chosen/ no_results_text:"xxxxx ...

  10. Kafka Eagle 源码解读

    1.概述 在<Kafka 消息监控 - Kafka Eagle>一文中,简单的介绍了 Kafka Eagle这款监控工具的作用,截图预览,以及使用详情.今天笔者通过其源码来解读实现细节.目 ...