# BUG - git clean

2 messages from 2013-10-11 to 2013-10-12. Participants: jones.noamle, Di Xu.
Thread: https://gitlist.dev/t/35108

## jones.noamle, 2013-10-11 18:53

Subject: BUG - git clean
Message-ID: <52584914.6030103@gmail.com>
URL: https://gitlist.dev/e/52584914.6030103%40gmail.com

```
Passing to git clean wrong (non-existent) paths together with valid 
ones, causes it to delete stuff that it shouldn't.
Am I right?
Script to reproduce:

mkdir test
cd test
git init .
mkdir ba
mkdir ba/ca

# So far so good.
# Should clean directory "ba/ca"
git clean -dn -- ba/ca

# Should clean "ba/ca" and ignore non-existent "j"
# Instead, it wants to delete "ba" totally.
git clean -dn -- ba/ca j

git --version

---------------------------------------------------------------------
Output:

+ mkdir test
+ cd test
+ git init .
Initialized empty Git repository in /home/notroot/test/.git/
+ mkdir ba
+ mkdir ba/ca
+ git clean -dn -- ba/ca
Would remove ba/ca/
+ git clean -dn -- ba/ca j
Would remove ba/
+ git --version
git version 1.7.9.5

---------------------------------------------------------------------

Thanks!
Noam

```

## Di Xu, 2013-10-12 10:36

Subject: Re: BUG - git clean
Message-ID: <loom.20131012T122854-19@post.gmane.org>
URL: https://gitlist.dev/e/loom.20131012T122854-19%40post.gmane.org
In-Reply-To: <52584914.6030103@gmail.com>

```
> mkdir test
> cd test
> git init .
> mkdir ba
> mkdir ba/ca
> 
> # So far so good.
> # Should clean directory "ba/ca"
> git clean -dn -- ba/ca
> 
> # Should clean "ba/ca" and ignore non-existent "j"
> # Instead, it wants to delete "ba" totally.
> git clean -dn -- ba/ca j

actually, my git will also do it wrong when 'j' exist, do
these after your script:

$ git clean -dn ba/ca j
Would remove ba/
$ mkdir j
$ git clean -dn ba/ca j
Would remove ba/ #here missing 'ca'
Would remove j/

I think it's the problem of directory path manipulation.

```
