GitHub is truly a treasure trove of open source, not only for learning code but also for learning how to use git!
Recently I studied the Off‑the‑Record‑iOS project (https://github.com/chrisballinger/Off-the-Record-iOS) and practiced using git submodules.
This project has a Submodules folder containing other open source projects it depends on. At first I did not notice, and just downloaded the ZIP. In XCode many file names showed up in red, revealing missing dependencies. There were quite a few, so I abandoned manual downloading.
Searching, I found issue #87 where someone asked the same question: https://github.com/chrisballinger/Off-the-Record-iOS/issues/87. Following the answer, I cloned the project with git and ran git submodule init && git submodule update (for git 1.6 and later you can use git clone –recursive). Updating worked for the first few submodules, but then a new error appeared:
Submodule path ‘Submodules/DAKeyboardControl’: checked out ‘5352d1ff2d1131d974d94406ed8fcf8eb068aa72’
Cloning into ‘Submodules/LibOrange’…
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Clone of ‘git@github.com:ChatSecure/LibOrange.git’ into submodule path ‘Submodules/LibOrange’ failed
Issue #105 also mentioned this: https://github.com/chrisballinger/Off-the-Record-iOS/issues/105. According to the author, the git URL needs to be updated to use https.
So in the project root, I edited .gitmodules, found the entry for LibOrange, and changed url = git@github.com:ChatSecure/LibOrange.git to url = https://github.com/ChatSecure/LibOrange.git then saved and exited.
After modifying the URL, updating still failed. After some attempts I realized the submodule URL must be resynchronized. Running git submodule sync refreshed the URL. Then running git submodule update –init produced:
fatal: Needed a single revision
Unable to find current revision in submodule path ‘Submodules/LibOrange’
This problem is explained here: http://blog.csdn.net/frank2336/article/details/7414545. The solution is to delete the existing folder with rm -rf LibOrange.
After deleting, back in the project root, running git submodule update –init worked without issue:
remote: Counting objects: 1052, done.
remote: Compressing objects: 100% (547/547), done.
remote: Total 1052 (delta 439), reused 1050 (delta 438)
Receiving objects: 100% (1052/1052), 3.96 MiB | 46 KiB/s, done.
Resolving deltas: 100% (439/439), done.
From https://github.com/ChatSecure/LibOrange
* branch HEAD -> FETCH_HEAD
Submodule path ‘Submodules/LibOrange’: checked out ‘d7ae559dfebe2eb6cc3996735fa6081e1aaa02fa’
This way the submodule cloned successfully and the project built correctly.
博主友情提示:
如您在评论中需要提及如QQ号、电子邮件地址或其他隐私敏感信息,欢迎使用>>博主专用加密工具v3<<处理后发布,原文只有博主可以看到。