0

I have cloned a "dotfiles" Git repository into my home directory and I'm trying to remove all the files associated with it.

How can I safely remove all files that belong to the repository without accidentally deleting any other files from my home directory?

mkrieger1
  • 19,194
  • 5
  • 54
  • 65
R Harrington
  • 253
  • 2
  • 10
  • How did you clone? Git usually creates a sub-directory for a cloned repo. You cn just remove it. – Serge Feb 02 '20 at 22:27

1 Answers1

0

You can use git ls-files to list the repository files and to pipe the output to rm

git ls-files | awk -F "/" '{print $1}' | sort | uniq | xargs rm -rf

After that delete the .git folder

rm -rf .git
Yuri G.
  • 4,323
  • 1
  • 17
  • 32