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

git add <single file> and git add <list of files> behave differentely for ignored files

From
GGuilherme <guibufolo@gmail.com>
Date
Dec 4, 2014, 09:06 UTC
Message-ID
<CAMDzUtzQJoEi17OfX8FPOV6SDJ_ytJSH-YTKx2DtUON35-EVSg@mail.gmail.com>
Hello,
I reported this issue on the git-user mailing list and they redirected me here.

The problem I have observed is that with a ignored path `git add <single file>` behaves differently then `git add <list of files>`.

I my git/info/excludes file i have

/COM/config !COM/config/Project.gny

The file COM/config/Project.gny has already been added to the repository via `git add -f`.

When doing
    git add -- COM/config/Projec.gny
git will not complain but when doing
    git add -- COM/config/Project.gny otherfiles.c
it will report:
    The following paths are ignored by one of your .gitignore files:
    COM/config
    Use -f if you really want to add them.
    fatal: no files added
This odd behaviour is also present in `git check-ignore`.

Before adding the file `git check-ignore` correctly reports the file as ignored. After having added it via `git add -f` it won't report it as ignored anymore.

Even if not a bug this behaviour is inconsistent and might want to be addressed as it makes scripting a little bit harder.

Thank you.
Next: Konstantin Khomoutov
Message 1 of 7 in “git add <single file> and git add <list of files> behave differentely for ignored files”
  1. GuilhermeDec 4, 2014
  2. Konstantin KhomoutovDec 4, 2014
  3. GuilhermeDec 4, 2014
  4. Michael J GruberDec 4, 2014
  5. check-ignore: clarify treatment of tracked filesMichael J Gruber, Dec 4, 2014
  6. Junio C HamanoDec 4, 2014
  7. Michael J GruberDec 8, 2014

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.