我在我的 Rails 3 项目中添加了一些 Haml 模板
git clone git://github.com/psynix/rails3_haml_scaffold_generator.git lib/generators/haml
只是发现,当我尝试编辑其中一些文件时,这是一个子模块,所以我无法提交我在lib/generators/haml
目录中所做的更改。现在每次我git status
,我得到
# On branch master
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: lib/generators/haml
#
no changes added to commit (use "git add" and/or "git commit -a")
但git add lib/generators/haml
没有效果。我真的只想拥有文件,而不是子模块,但我发现子模块无法摆脱:
> git rm --cached lib/generators/haml
rm 'lib/generators/haml'
> git status
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# deleted: lib/generators/haml
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# lib/generators/
> git commit -m "Removed submodule"
[master 02ae4c7] Removed submodule
1 files changed, 0 insertions(+), 1 deletions(-)
delete mode 160000 lib/generators/haml
> git status
# On branch master
# Your branch is ahead of 'origin/master' by 1 commit.
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# lib/generators/
nothing added to commit but untracked files present (use "git add" to track)
> git add lib/generators/haml
> git status
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# new file: lib/generators/haml
#
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: lib/generators/haml
> git commit -m "Re-added lib/generators/haml"
[master c966912] Re-added lib/generators/haml
1 files changed, 1 insertions(+), 0 deletions(-)
create mode 160000 lib/generators/haml
> git status
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: lib/generators/haml
额外git add
的 s 是没用的。如果我尝试git rm -rf lib/generators/haml
,我会得到
fatal: git rm: 'lib/generators/haml': Operation not permitted
它只是不会死!我查找了如何删除 submodules,但在这种情况下,没有.submodules
文件,也没有提及.git/config
. 然而,如果我跑步git submodule update
,我会得到
No submodule mapping found in .gitmodules for path 'lib/generators/haml'
我删除了目录,但我得到了相同的结果!这是怎么回事?我是否需要创建一个.gitmodules
文件来删除子模块?