Ответ 1
Это не ошибка, это документированное поведение. От man git-clean
:
Если директория без трекинга управляется другим репозиторием git, она не удаляется по умолчанию.
Каталог submod
- это другой репозиторий git
; если вы хотите удалить его, Use -f option twice if you really want to remove such a directory
.
git clean -f -f -d submod
удаляет submod
. Смотрите мои шаги ниже (почти идентичные, разные git version
и жестко закодированные submodule
пути, потому что иначе git
плюет манекен).
Действия
$ 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"
Добавить submod
как ветвь git submodule
в topic1
.
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
, а затем 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)