rm -rf失败时如何删除.git目录?

时间:2020-09-01 18:12:45

标签: linux git remove .git-folder

我正在尝试通过运行以下命令来删除与项目关联的git文件:

[#]: rm -rf .git

我得到以下结果:

rm: cannot remove ‘.git/hooks’: Directory not empty

.git/hooks,我试图看清ls -l并得到了这个奇怪的答复:

ls: cannot access commit-msg.sample: No such file or directory
ls: cannot access pre-rebase.sample: No such file or directory
ls: cannot access applypatch-msg.sample: No such file or directory
ls: cannot access pre-commit.sample: No such file or directory
ls: cannot access update.sample: No such file or directory
ls: cannot access pre-applypatch.sample: No such file or directory
ls: cannot access post-update.sample: No such file or directory
applypatch-msg.sample  pre-applypatch.sample  update.sample
commit-msg.sample      pre-commit.sample
post-update.sample     pre-rebase.sample

我尝试单独删除这些文件,但也不起作用。例如:

[#]: rm applypatch-msg.sample
rm: cannot remove ‘applypatch-msg.sample’: No such file or directory

如何从项目中删除此git目录?

1 个答案:

答案 0 :(得分:-2)

尝试

 rmdir .git

 rm -r .git