2012-08-30 47 views
12

我換一個git子模塊的承諾指針:如何放棄對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") 

這裏的DIFF:

% 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 

知道爲什麼這發生?

謝謝!

回答

16

當它們中的SHA發生更改時,Git不會自動更新子模塊。

您可能需要git submodule update這將對子模塊回預期SHA, 或git add app/lib這將預期SHA更改爲輔助模塊中的電流值。