git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Gitignore file exceptions are not applied to untarcked files

From
Anatoly Borodin <anatoly.borodin@gmail.com>
Date
Jan 29, 2016, 20:54 UTC
Message-ID
<n8gji4$bf1$1@ger.gmane.org>
In-Reply-To
<xmqqd1skjkyp.fsf@gitster.mtv.corp.google.com>
Hi Junio,

I've tested it with many older versions of git, as well as with the recent v2.7.0 - it seems like this feature has been never working properly.

The script https://gist.github.com/anatolyborodin/9c581b50c584534fff28
#!/bin/sh
set -e

# a # b # c # D/a # D/b # D/c # E/F/a # E/F/b # E/F/c

mkdir -p D E/F touch a b c D/a D/b D/c E/F/a E/F/b E/F/c

echo && echo '.gitignore' && echo '----------' echo '*\n!b\n!D/b\n!/D/b\n!/E/*/b' > .gitignore cat .gitignore

echo && echo 'With `--ignored`' && echo '----------' git status --ignored

echo && echo 'Without `--ignored`' && echo '----------' git status

The output:

.gitignore ---------- * !b /D/b !/D/b !/E/*/b

With `--ignored`
----------
On branch master
Your branch is up-to-date with 'origin/master'.
Untracked files:
  (use "git add <file>..." to include in what will be committed)
        b
Ignored files:
  (use "git add -f <file>..." to include in what will be committed)
        .gitignore
        D/
        E/
        a
        c
nothing added to commit but untracked files present (use "git add" to track)
Without `--ignored`
----------
On branch master
Your branch is up-to-date with 'origin/master'.
Untracked files:
  (use "git add <file>..." to include in what will be committed)
        b
nothing added to commit but untracked files present (use "git add" to track)
All files in the subdirectories are ignored, no matter what.
-- 
Mit freundlichen Grüßen,
Anatoly Borodin
Previous: Junio C Hamano
Message 3 of 3 in “Gitignore file exceptions are not applied to untarcked files”
  1. Assen TotinJan 29, 2016
  2. Junio C HamanoJan 29, 2016
  3. Anatoly BorodinJan 29, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.