Git repos have lots of write protected files in the .git
directory, sometimes hundreds, and the default rm my_project_managed_by_git
will prompt before deleting each write protected file. So, to actually delete my project I have to do rm -rf my_project_managed_by_git
.
Using rm -rf
scares me. Is there a reasonable way to delete git repos without it?
Using rm -rf scares me. Is there a reasonable way to delete git repos without it?
I don’t know what to tell you, that’s the command you need to use.
If you’re that worried you’re going to nuke important stuff, make backups, and don’t use
sudo
for user files.use relative paths (cd into the directory below your repository) and use tab completion, and you won’t have problems.
chmod -R 777 my_project_managed_by_git && rm -r my_project_managed_by_git
So… you’re afraid of the command that does the thing you’re trying to do?
More like, I’m afraid of the command doing more than I’m trying to do.
What I want to do is ignore prompts about write-protected files in the
.git
directory, what it does is ignore all prompts for all files.so why not
rm -rf folder/.git/*
thenrm -r folder/*
Maybe they’re afraid of accidentally writing
rm -rf folder/.git /*
or somethingGenerally that is not a concern because regular users won’t be able to
rm
anything else other than those in his own $HOME.Another thing I want to say is, command line is for careful users. If someone is careless, they should create a wrapper around
rm
, or just use a FM.If someone is careless, they should create a wrapper around rm, or just use a FM.
I think that’s the situation OP is in… They don’t trust themself with these kinds of commands, while other commenters here are trying to convince them that they should just use rm -rf anyway
A tip I saw some time ago is to do:
rm folder -rf
Additionally you could move the git folder to the trash folder. I think it’s usually located at $HOME/.local/share/trash/files/
Then you can delete it from the trash once you’re certain you got the right folder
Additionally you could move the git folder to the trash folder. I think it’s usually located at $HOME/.local/share/trash/files/
Moving something to the trash files folder isn’t the correct way to trash it, since the Trash specification requires storing some metadata for each trash item.
You should use eg.
trash-cli
instead.xdg-trash
Maybe use a graphical file manager?
Or move the folder to /tmp or so.
That’s a good suggestion for some, but I’m quite comfortable with the command line.
It’s not that I’m irrationally scared of
rm -rf
. I know what that command will do. If I slow down an pay attention it’s not as though I’m worried “I hope this doesn’t break my system”.What I really mean is I see myself becoming quite comfortable typing
rm -rf
and running it with little thought, I use it often to delete git repos, and my frequent use and level of comfort with this command doesn’t match the level of danger it brings.Just moving them to
/tmp
is a nice suggestion that can work on anywhere without special programs or scripts.You don’t sound like you’re comfortable with the command line.