Re: Bug Report: .gitignore behavior is not matching in git clean and git status
- From
Junio C Hamano <gitster@pobox.com>
- Date
- May 1, 2017, 01:41 UTC
- Message-ID
- <xmqq60hljqud.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <CABfTTAchc61aB02sCD=Oa9gRMGr94h7mC53B9q6Qy2k2hDqzAQ@mail.gmail.com>
Chris Johnson <chrisjohnson0@gmail.com> writes:
Show 8 quoted lines
> I am a mailing list noob so I’m sorry if this is the wrong format or > the wrong please. > > Here’s the setup for the bug (I will call it a bug but I half expect > somebody to tell me I’m an idiot): > > git init > echo "/A/B/" > .gitignore
You tell Git that anything in A/B/ are uninteresting.
> git add .gitignore && git commit -m 'Add ignore' > mkdir -p A/B > touch A/B/C
And create an uninteresting cruft.
> git status
And Git does not bug you about it.
> git clean -dn
This incorrectly reports "Would remove A/" and if you gave 'f' instead of 'n', it does remove A/, A/B, and A/B/C.
Despite that "git clean --help" says 'only files unknown to Git are removed' (with an undefined term 'unknown to Git'). What it wants the term mean can be guessed by seeing 'if the -x option is specified, ignored files are also removed'---so 'unknown to Git' does not include what you told .gitignore that they are uninteresting. IOW, Git knows they are not interesting.
It looks like a bug in "git clean -d" to me. Do you see the same issue if you use "git clean" without "-d"? IOW, does it offer to remove A/B/C?