[英]How to discard change to git submodule?
我更改了git子模块的提交指针:
% git status
# On branch fix
# Your branch is behind 'origin/fix' by 1 commit, and can be fast-forwarded.
#
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: app/lib (new commits)
#
no changes added to commit (use "git add" and/or "git commit -a")
但是当我执行git checkout
,什么都没有改变:
% git checkout -- app/lib && git status
# On branch fix
# Your branch is behind 'origin/fix' by 1 commit, and can be fast-forwarded.
#
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: app/lib (new commits)
#
no changes added to commit (use "git add" and/or "git commit -a")
这是差异:
% git diff
diff --git a/app/lib b/app/lib
index d670460..83baae6 160000
--- a/app/web-lib
+++ b/app/web-lib
@@ -1 +1 @@
-Subproject commit d670460b4b4aece5915caf5c68d12f560a9fe3e4
+Subproject commit 83baae61804e65cc73a7201a7252750c76066a30
知道为什么会这样吗?
谢谢!
当子模块中的SHA更改时,Git不会自动更新子模块。
您要么需要git submodule update
来将子模块恢复到预期的SHA,要么需要git add app/lib
来将期望的SHA更改为子模块中的当前值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.