Using git clean to remove subdirectories containing git repositories

I had a peculiar situation today where I cloned a repository into a directory which was inside another repository. Here’s what I was doing:

$ git clone git://gitserver/repo1.git repo1
$ cd repo1
$ git clone git://gitserver/repo2.git repo2
$ git clean -fxd
Removing repo2/
$ ls -d repo2
repo2

The second repository existed even after a git clean -fxd. I stumbled upon a GitHub page within the capistrano project that explained the problem — an extra -f was required:

$ git clean -ffxd
Removing repo2/
$ ls -d repo2 
ls: cannot access repo2: No such file or directory
Tagged , ,

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>