# git bug

5 messages from 2020-08-06 to 2020-08-10. Participants: PANEL Christian, René Scharfe, Jeff King.
Thread: https://gitlist.dev/t/54002

## PANEL Christian, 2020-08-06 14:48

Subject: git bug
Message-ID: <1596725319.6764.7.camel@free.fr>
URL: https://gitlist.dev/e/1596725319.6764.7.camel%40free.fr

```
someting is not logical in the behaviour of git :

suppose I have a project and a file in it I don't want to include initially in.
so I put this file name in .gitignore
now all is OK when I write "git status" : the file is ignored.

but later I want this one be a part of my project.
I delete in .gitignore the line that named this file.
but now a "git status" command ignore always this file.

what is wrong ?
did I missed something ?

thanks for any answer 

```

## René Scharfe, 2020-08-06 20:23

Subject: Re: git bug
Message-ID: <5387a5b7-4551-53a0-abdb-e26cc2702536@web.de>
URL: https://gitlist.dev/e/5387a5b7-4551-53a0-abdb-e26cc2702536%40web.de
In-Reply-To: <1596725319.6764.7.camel@free.fr>

```
Am 06.08.20 um 16:48 schrieb PANEL Christian:
> someting is not logical in the behaviour of git :
>
> suppose I have a project and a file in it I don't want to include initially in.
> so I put this file name in .gitignore
> now all is OK when I write "git status" : the file is ignored.

Like this, right?

  $ git init a
  Initialized empty Git repository in /tmp/a/.git/
  $ cd a
  $ echo ignore for now >file
  $ echo file >.gitignore
  $ git add .gitignore
  $ git commit -m initial
  [master (root-commit) 2df5d68] initial
   1 file changed, 1 insertion(+)
   create mode 100644 .gitignore
  $ git status
  On branch master
  nothing to commit, working tree clean

> but later I want this one be a part of my project.
> I delete in .gitignore the line that named this file.
> but now a "git status" command ignore always this file.
>
> what is wrong ?
> did I missed something ?

This seems to work as expected for me (continued from above):

  $ >.gitignore
  $ git status
  On branch master
  Changes not staged for commit:
    (use "git add <file>..." to update what will be committed)
    (use "git restore <file>..." to discard changes in working directory)
  	modified:   .gitignore

  Untracked files:
    (use "git add <file>..." to include in what will be committed)
  	file

  no changes added to commit (use "git add" and/or "git commit -a")

So "file" is no longer ignored.  Committing the .gitignore change
doesn't change that:

  $ git add .gitignore
  $ git commit -m 2nd
  [master d4c95a1] 2nd
   1 file changed, 1 deletion(-)
  $ git status
  On branch master
  Untracked files:
    (use "git add <file>..." to include in what will be committed)
  	file

  nothing added to commit but untracked files present (use "git add" to track)

Which steps did you take to arrive at a different result?

René

```

## Jeff King, 2020-08-07 00:02

Subject: Re: git bug
Message-ID: <20200807000226.GA12088@coredump.intra.peff.net>
URL: https://gitlist.dev/e/20200807000226.GA12088%40coredump.intra.peff.net
In-Reply-To: <5387a5b7-4551-53a0-abdb-e26cc2702536@web.de>

```
On Thu, Aug 06, 2020 at 10:23:54PM +0200, René Scharfe wrote:

> So "file" is no longer ignored.  Committing the .gitignore change
> doesn't change that:
> 
>   $ git add .gitignore
>   $ git commit -m 2nd
>   [master d4c95a1] 2nd
>    1 file changed, 1 deletion(-)
>   $ git status
>   On branch master
>   Untracked files:
>     (use "git add <file>..." to include in what will be committed)
>   	file
> 
>   nothing added to commit but untracked files present (use "git add" to track)
> 
> Which steps did you take to arrive at a different result?

Perhaps also:

  git check-ignore -v file

would be helpful for seeing why Git thinks it might be ignored (e.g.,
another wildcard rule that happens to match it).

-Peff

```

## René Scharfe, 2020-08-10 05:56

Subject: Re: git bug
Message-ID: <c223cb39-501f-8ed1-9b82-2f7c2cb22886@web.de>
URL: https://gitlist.dev/e/c223cb39-501f-8ed1-9b82-2f7c2cb22886%40web.de
In-Reply-To: <20200807000226.GA12088@coredump.intra.peff.net>

```
Am 07.08.20 um 02:02 schrieb Jeff King:
> On Thu, Aug 06, 2020 at 10:23:54PM +0200, René Scharfe wrote:
>
>> So "file" is no longer ignored.  Committing the .gitignore change
>> doesn't change that:
>>
>>   $ git add .gitignore
>>   $ git commit -m 2nd
>>   [master d4c95a1] 2nd
>>    1 file changed, 1 deletion(-)
>>   $ git status
>>   On branch master
>>   Untracked files:
>>     (use "git add <file>..." to include in what will be committed)
>>   	file
>>
>>   nothing added to commit but untracked files present (use "git add" to track)
>>
>> Which steps did you take to arrive at a different result?
>
> Perhaps also:
>
>   git check-ignore -v file
>
> would be helpful for seeing why Git thinks it might be ignored (e.g.,
> another wildcard rule that happens to match it).

Right.  And there is more than one possible place to specify files to be
ignored.  E.g. you can use info/exclude in your Git directory (i.e.
.git/info/exclude by default) for repository-specific patterns don't
want to share.  See https://git-scm.com/docs/gitignore or the manpage
of gitignore(5) for more details.

René

```

## PANEL Christian, 2020-08-10 17:20

Subject: Re: git bug
Message-ID: <1597080038.3096.1.camel@free.fr>
URL: https://gitlist.dev/e/1597080038.3096.1.camel%40free.fr
In-Reply-To: <c223cb39-501f-8ed1-9b82-2f7c2cb22886@web.de>

```
thanks a lot.
It was exactly what I was seaching (and havent' read yet ;) )

best regards

Le lundi 10 août 2020 à 07:56 +0200, René Scharfe a écrit :
> Am 07.08.20 um 02:02 schrieb Jeff King:
> > 
> > On Thu, Aug 06, 2020 at 10:23:54PM +0200, René Scharfe wrote:
> > 
> > > 
> > > So "file" is no longer ignored.  Committing the .gitignore change
> > > doesn't change that:
> > > 
> > >   $ git add .gitignore
> > >   $ git commit -m 2nd
> > >   [master d4c95a1] 2nd
> > >    1 file changed, 1 deletion(-)
> > >   $ git status
> > >   On branch master
> > >   Untracked files:
> > >     (use "git add <file>..." to include in what will be committed)
> > >   	file
> > > 
> > >   nothing added to commit but untracked files present (use "git add" to track)
> > > 
> > > Which steps did you take to arrive at a different result?
> > Perhaps also:
> > 
> >   git check-ignore -v file
> > 
> > would be helpful for seeing why Git thinks it might be ignored (e.g.,
> > another wildcard rule that happens to match it).
> Right.  And there is more than one possible place to specify files to be
> ignored.  E.g. you can use info/exclude in your Git directory (i.e.
> .git/info/exclude by default) for repository-specific patterns don't
> want to share.  See https://git-scm.com/docs/gitignore or the manpage
> of gitignore(5) for more details.
> 
> René


```
