我的一个git子模块总是检查一个特定的提交:
首先,它在主存储库中显示为已修改:
% git status
On branch master
Your branch is ahead of 'origin/master' by 3 commits.
(use "git push" to publish your local commits)
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: wp-content/themes/site-wp-theme (new commits)
这是git submodule status
% git submodule status
+9eb1fbd567d588b44105487d368ff7d12b5fd50b wp-content/themes/site-wp-theme (heads/master)
15466ab74c20f67ef8ca04e7841d02e85323d36c wp-content/themes/wp-siteny-theme (heads/master)
尝试更新:
% git submodule update
warning: unable to rmdir admin/inc/cmb: Directory not empty
warning: unable to rmdir admin/inc/redux: Directory not empty
Submodule path 'wp-content/themes/site-wp-theme': checked out 'c010f3a0b6e5c4721d8e79d312b1fffa342340b8'
然后我必须转到子模块,然后执行git checkout master
来恢复它,这会使其在git status
上再次显示为已修改。
这是我的.gitmodules
文件:
[submodule "site"]
path = wp-content/themes/site-wp-theme
url = https://ajf-@bitbucket.org/ajf-/site-wp-theme.git
fetchRecurseSubmodules = true
ignore = untracked
[submodule "siteny"]
path = wp-content/themes/wp-siteny-theme
url = https://ajf-@bitbucket.org/ajf-/wp-siteny-theme.git
fetchRecurseSubmodules = true
ignore = untracked
我该如何解决这个问题?
答案 0 :(得分:1)
git submodule update
会使父repo更新它注册的SHA1的子模块,而不是你在该子模块中修改的SHA1。
如果父仓库的状态显示子模块的修改后的SHA1,您所要做的就是:
mode 160000
)。答案 1 :(得分:0)
git submodule update
检查git认为应该在的提交的所有子模块;它就像子模块的git checkout .
。
相反,您想通过将该修订提交给父代表来告诉git 9eb1fbd
是应该的那个。
这样做: