这不是错误,而是已记录的行为。从man git-clean
:
如果未跟踪的目录由不同的 git 存储库管理,则默认情况下不会将其删除。
The submod
目录不同git
存储库;如果你想删除它,Use -f option twice if you really want to remove such a directory
.
git clean -f -f -d submod
does remove submod
。请参阅下面的我的步骤(几乎相同;不同git version
和硬编码的submodule
路径,因为否则git
假人吐口水)。
Steps
$ git --version
git version 1.7.5.4 # Note, different git-version.
制作两个存储库
git init submod
cd submod
echo "This is a submodule" > README.txt
git add .
git commit -m "Initial commit"
cd ..
git init prog
cd prog
echo "This is a program" > README.txt
git add .
git commit -a -m "Initial commit"
Add submod
as a git submodule
in topic1
branch.
git checkout -b topic1
git submodule add /Users/simont/sandbox/SOTESTING/Subdir-testing/submod
git commit -m "Added submodule"
现在是有趣的部分。
$ git checkout master
warning: unable to rmdir submod: Directory not empty
Switched to branch 'master'
git status
# On branch master
# Untracked files:
# (use "git add ..." to include in what will be committed)
#
# submod/
#nothing added to commit but untracked files present (use "git add" to track)
尝试git-clean
, then actually git-clean
.
git clean -fd
#Removing submod/
git status
# On branch master
# Untracked files:
# (use "git add ..." to include in what will be committed)
#
# submod/
#nothing added to commit but untracked files present (use "git add" to track)
$ # As we can see, we haven't actually removed anything yet.
$ ls
README.txt submod
$ git clean -f -f -d submod
Removing submod/
$ ls
README.txt
$ git status
# On branch master
nothing to commit (working directory clean)