git 子模块在父目录中显示为已更改
git submodule shows as changed in parent directory
我的项目中有一个库作为 git 子模块 签出,我经常在库中进行更改。每次我提交更改时,父仓库中的后续 git status
都会显示子模块已更改。我还使用 __git_ps1
,因此父目录提示显示有未提交的更改。
parent-project (master *) $ git diff
diff --git a/my-submodule b/my-submodule
index 5eb2e9f..fd40630 160000
--- a/my-submodule
+++ b/my-submodule
@@ -1 +1 @@
-Subproject commit 5eb2e9fdcb85ab5a1f57e622b17cc76e5af749b7
+Subproject commit fd406308851b5521980f4578960c428200c66371
我知道有两个选择:
来自父级的 git commit submodule
创建不必要的提交,或
- 删除并重新添加看起来有点矫枉过正的子模块。
有没有办法告诉父仓库将子模块引用更新到最新的主模块并继续?我不想提及特定的 git 修订版,只是针对 master 的负责人或我选择的任何分支。
谢谢!
Is there any way to tell the parent repo Update the submodule ref to the latest master
是的,--remote
option:
git submodule update --remote
and move on?
好吧,...这仍然会更改子模块 SHA1 树,因此您仍然需要进行提交,但是只要您在父存储库中进行了自己的更改,就可以进行上述提交。
也许你可以在本地忽略它:
cd /parent/repo
git update-index --assume-unchanged -- submoduleFolder # no trailing slash
我的项目中有一个库作为 git 子模块 签出,我经常在库中进行更改。每次我提交更改时,父仓库中的后续 git status
都会显示子模块已更改。我还使用 __git_ps1
,因此父目录提示显示有未提交的更改。
parent-project (master *) $ git diff
diff --git a/my-submodule b/my-submodule
index 5eb2e9f..fd40630 160000
--- a/my-submodule
+++ b/my-submodule
@@ -1 +1 @@
-Subproject commit 5eb2e9fdcb85ab5a1f57e622b17cc76e5af749b7
+Subproject commit fd406308851b5521980f4578960c428200c66371
我知道有两个选择:
-
来自父级的
git commit submodule
创建不必要的提交,或- 删除并重新添加看起来有点矫枉过正的子模块。
有没有办法告诉父仓库将子模块引用更新到最新的主模块并继续?我不想提及特定的 git 修订版,只是针对 master 的负责人或我选择的任何分支。
谢谢!
Is there any way to tell the parent repo Update the submodule ref to the latest master
是的,--remote
option:
git submodule update --remote
and move on?
好吧,...这仍然会更改子模块 SHA1 树,因此您仍然需要进行提交,但是只要您在父存储库中进行了自己的更改,就可以进行上述提交。
也许你可以在本地忽略它:
cd /parent/repo
git update-index --assume-unchanged -- submoduleFolder # no trailing slash