问题
如下报错,是因为子模块中出现变更导致的。在我们想保留变更,又不想将其添加到子模块的gitignore
文件中的时候,应该怎么办呢?
➜ expwdx.github.io git:(gh-pages) git status
On branch gh-pages
Your branch is up to date with 'origin/gh-pages'.
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)
(commit or discard the untracked or modified content in submodules)
modified: themes/fluid (untracked content)
解决办法
如下图所示,在gitmodule
文件中的对应子模块配置中增加ignore = dirty
即可。
- vim .gitmodule
[submodule "themes/3-hexo"]
path = themes/3-hexo
url = git@github.com:yelog/hexo-theme-3-hexo.git
[submodule "themes/next"]
path = themes/next
url = git@github.com:theme-next/hexo-theme-next.git
[submodule "themes/yilia"]
path = themes/yilia
url = git@github.com:litten/hexo-theme-yilia.git
[submodule "themes/material"]
path = themes/material
url = git@github.com:viosey/hexo-theme-material.git
[submodule "themes/fluid"]
path = themes/fluid
url = git@github.com:fluid-dev/hexo-theme-fluid.git
ignore = dirty
- git diff
diff --git a/.gitmodules b/.gitmodules
index ad752a7..de11a01 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -13,3 +13,4 @@
[submodule "themes/fluid"]
path = themes/fluid
url = git@github.com:fluid-dev/hexo-theme-fluid.git
+ ignore = dirty
(END)