git submodule update - 为什么从顶层开始

标签 git git-submodules

我一直对此感到困惑:

$ git submodule
You need to run this command from the toplevel of the working tree.

为什么我需要从顶级目录运行它?是技术原因,还是仅仅因为约定/可能的缺陷?

最佳答案

注意:从 git 1.8.4(2013 年 8 月)开始,commit 091a6eb , 你不必在顶层运行 git submodule update .
这是因为 git rev-parse 有一个新的 --prefix选项。

--prefix <arg>

Behave as if git rev-parse was invoked from the <arg> subdirectory of the working tree.
Any relative filenames are resolved as if they are prefixed by <arg> and will be printed in that form.

git submodule add as well 没有同样的限制。 .

关于git submodule update - 为什么从顶层开始,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21856214/

相关文章:

Git子模块更新

git - 如何列出包含提交的所有标签?

ios - RestKit 作为 Git 子模块安装后出现错误

git - 为什么我只是将文件添加到暂存区,Git 会将文件存储在存储库中?

git - “git pull”在 merge 冲突期间将其他人的提交带到我的暂存区

Git 日志不显示子模块更改

git - 编辑 git 子模块

ruby-on-rails - 在两个或多个 Rails 应用程序之间共享代码……git 子模块的替代方案?

git - 将 git repo 的一部分作为子模块添加到另一部分

git - 如何用git管理多个相似但不同的项目?