简体   繁体   中英

How to remove .git directory when rm -rf fails?

I am trying to remove the git files associated with a project by running:

[#]: rm -rf .git

I get the following result:

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

Looking in .git/hooks I have tried to see ls -l what is there and I get this weird response:

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

I have tried to remove these files individually and that does not work either. Eg:

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

How can I remove this git directory from the project?

I am trying to remove the git files associated with a project by running:

[#]: rm -rf .git

I get the following result:

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

Looking in .git/hooks I have tried to see ls -l what is there and I get this weird response:

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

I have tried to remove these files individually and that does not work either. Eg:

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

How can I remove this git directory from the project?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM