DEV Community

Discussion on: Deleting Git Repo. Blocked by SymLinks

Collapse
 
moopet profile image
Ben Sinclair • Edited

Have you tried finding all the symlinks (try find .Trash-1003 -type l in the first instance) and deleting them individually?

I suspect that rm is following the links down to delete the nodes first, then backing up the tree. If a symlink is pointing to itself, its parent, or another symlink which is pointing, in turn, to one of those, then rm will recurse forever.

Running find without the -L option should mean it doesn't try to recurse within linked directories, so it shouldn't get the same problem as rm.

There're probably just one or two problem links and using rm on them one a time should work.

Collapse
 
emgodev profile image
Michael

Your solution might've worked too, but I didn't test it when I moved it off the external usb.

Collapse
 
emgodev profile image
Michael
.Trash-1003
.Trash-1003/files
.Trash-1003/files/.git
.Trash-1003/files/.git/objects
.Trash-1003/files/.git/objects/8f
.Trash-1003/files/.git/objects/8f/*
find: ‘.Trash-1003/files/.git/objects/8f/*/*’: Too many levels of symbolic links
.Trash-1003/files/.git/objects/8f/*/.. (
find: ‘.Trash-1003/files/.git/objects/8f/*/.. (/8f’: Too many levels of symbolic links
.Trash-1003/files/.git/objects/8f/.. (
find: ‘.Trash-1003/files/.git/objects/8f/.. (/8f’: Too many levels of symbolic links

It looks like it's the */ and (/, but deleting those just throws that same error.

Collapse
 
daemoen profile image
Marc Mercer

surprised you didn't suggest -exec rm -rf {} \; as an addon to the find....

Though, in the case of unusual issues, I tend to prefer going a bit deeper than most people, why not use the inode reference and delete it specifically by inode, though in this particular case, that should be drastically overkill.

rm -rf ./.git should be sufficient.

Collapse
 
moopet profile image
Ben Sinclair

I didn't suggest that because I don't see how it'd be any better than the original attempt - we've already established that rm -rf doesn't work if the directory contains some kind of self-reference. I'm not sure why the find came out with that output though, because it looks like it's reporting a lot of things that shouldn't be links.
I don't really know though, I'm just guessing.