I was trying to remove all git files from a repository with this:
find . -name ".git*" -exec rm -rf {} \;
However, rm
warns that files could not be deleted (because their parent directory has already been deleted).
Is there a way to get find
to stop recursing when it finds a matching directory?
Eg find...
/.gitmodules
/.git/stuff
/.git/.gitfile
... produces
/.gitmodules
/.git
Use -depth
:
find . -depth -name ".git*" -exec rm -rf {} \;
This would allow you to process the files or subdirectories first before their parent directories.
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.