# "git grep --no-index" doesn't do what it says on the tin?

2 messages from 2013-05-15 to 2013-05-15. Participants: Nazri Ramliy, Antoine Pelisse.
Thread: https://gitlist.dev/t/33821

## Nazri Ramliy, 2013-05-15 05:32

Subject: "git grep --no-index" doesn't do what it says on the tin?
Message-ID: <CAEY4ZpP8txhCCmw-Ck7_rQL+Xn4bJw-RgVa7iDaHzQ6mcS5oLQ@mail.gmail.com>
URL: https://gitlist.dev/e/CAEY4ZpP8txhCCmw-Ck7_rQL%2BXn4bJw-RgVa7iDaHzQ6mcS5oLQ%40mail.gmail.com

```
Hi,

>From "git help grep":

      --no-index
           Search files in the current directory that is not managed by Git.

       --untracked
           In addition to searching in the tracked files in the working tree,
           search also in untracked files.

>From the description above I would think that "git grep --no-index"
and "git grep --untracked" would behave differently, but it seems like
their behavior is the same:

        $ cd ~/src/git
        $ echo superman >> git.c
        $ echo superman >> foo.txt
        $ git grep --no-index superman
        foo.txt:1:superman
        git.c:588:superman
        $ git grep --untracked superman
        foo.txt:1:superman
        git.c:588:superman

I would expect the following behavior for "git grep --no-index":

        $ git grep --no-index superman
        foo.txt:1:superman
        $

That is, it won't search inside files that are managed by git.

nazri

```

## Antoine Pelisse, 2013-05-15 06:54

Subject: Re: "git grep --no-index" doesn't do what it says on the tin?
Message-ID: <CALWbr2wq7QtTXp=tDn27g6_XQjou9FfCvPkXHxmxqws4nTUwxA@mail.gmail.com>
URL: https://gitlist.dev/e/CALWbr2wq7QtTXp%3DtDn27g6_XQjou9FfCvPkXHxmxqws4nTUwxA%40mail.gmail.com
In-Reply-To: <CAEY4ZpP8txhCCmw-Ck7_rQL+Xn4bJw-RgVa7iDaHzQ6mcS5oLQ@mail.gmail.com>

```
On Wed, May 15, 2013 at 7:32 AM, Nazri Ramliy <ayiehere@gmail.com> wrote:
> Hi,
>
> From "git help grep":
>
>       --no-index
>            Search files in the current directory that is not managed by Git.
>
>        --untracked
>            In addition to searching in the tracked files in the working tree,
>            search also in untracked files.

The difference is in the "not managed by Git". Inside a repository,
they will do the same thing. But only the first can work outside a
repository.

Cheers,
Antoine

```
