背景
在Linux上使用Git 1.8.1.1。存储库如下所示:
master
book
子模块的创建如下:
$ cd /path/to/master
$ git submodule add https://user@bitbucket.org/user/repo.git book
该book
子模块是干净的:
$ cd /path/to/master/book/
$ git status
# On branch master
nothing to commit, working directory clean
问题
另一方面,母版显示book子模块有“新提交”:
$ cd /path/to/master/
$ git status
# On branch master
# 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: book (new commits)
#
no changes added to commit (use "git add" and/or "git commit -a")
Git应该完全忽略子模块目录,这样母版也是干净的:
$ cd /path/to/master/
$ git status
# On branch master
nothing to commit, working directory clean
尝试失败1-脏
master/.gitmodules
根据此答案,文件内包含以下内容:
[submodule "book"]
path = book
url = https://user@bitbucket.org/user/repo.git
ignore = dirty
尝试失败#2-未跟踪
master/.gitmodules
根据此答案更改为以下内容:
[submodule "book"]
path = book
url = https://user@bitbucket.org/user/repo.git
ignore = untracked
尝试失败#3-showUntrackedFiles
master/.git/config
根据此答案编辑为以下内容:
[status]
showUntrackedFiles = no
尝试失败4-忽略
将book目录添加到主忽略文件中:
$ cd /path/to/master/
$ echo book > .gitignore
尝试失败#5-克隆
将书目录添加到母版,如下所示:
$ cd /path/to/master/
$ rm -rf book
$ git clone https://user@bitbucket.org/user/repo.git book
题
book
子模块如何位于存储库下自己的存储库目录中,master
而git却忽略了该book
子模块?也就是说,不应显示以下内容:
#
# modified: book (new commits)
#
git status
在主存储库中执行时如何隐藏该消息?
一篇关于git子模块陷阱的文章表明这是不合适的子模块用法吗?