git子模块在父目录中显示为已更改 [英] git submodule shows as changed in parent directory

查看:204
本文介绍了git子模块在父目录中显示为已更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的项目中有一个作为 git子模块签出的库,我经常在lib中进行更改.每次我提交更改时,父存储库中的后续git status都会显示子模块已更改.我也使用__git_ps1,因此父目录提示显示有未提交的更改.

I've got a library checked out as a git submodule in my project and I often make changes in the lib. Every time I commit that change the subsequent git status in the parent repo shows that the submodule has changed. I also use __git_ps1 and so the parent dir prompt shows that there are uncommitted changes.

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

我知道两个选择:

    来自父级的
  1. git commit submodule会创建不必要的提交,或者
  2. 删除并重新添加似乎过大的子模块.
  1. git commit submodule from the parent which creates unnecessary commits, or
  2. remove and re-add the submodule which seems like an overkill.

有什么办法告诉父仓库将子模块ref更新为最新的master并继续?我不想引用特定的git版本,而只引用 master 的头或我选择的任何分支.

Is there any way to tell the parent repo Update the submodule ref to the latest master and move on? I don't want to refer to a specific git revision, just to the head of master or whatever branch I choose.

谢谢!

推荐答案

有什么办法告诉父仓库吗?将子模块ref更新为最新的master

Is there any way to tell the parent repo Update the submodule ref to the latest master

是,使用 --remote选项:

Yes, with the --remote option:

git submodule update --remote

继续前进吗?

and move on?

嗯,...这仍然会更改子模块SHA1树,因此您仍然需要进行提交,但是只要在父存储库中进行了自己的更改,就可以进行所说的提交.

Well,... that would still change the submodule SHA1 tree, so you would still need to make a commit, but you can make said commit whenever you have made your own changes in the parent repository.

也许在本地,您可以通过以下方式忽略它:

Maybe locally you could ignore that with:

cd /parent/repo
git update-index --assume-unchanged -- submoduleFolder # no trailing slash

这篇关于git子模块在父目录中显示为已更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆