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

[BUG] spurious failure when adding tracked file in ignored directory

From
CSChristian Sattler <sattler.christian@gmail.com>
Date
Oct 25, 2024, 23:30 UTC
Message-ID
<CALCpNBqfGRh3U6HpJDfUQyLOckz-hRJw2_2GRZfSFqXAyRY12g@mail.gmail.com>

Adding a tracked file in an ignored directory causes a spurious warning and exit code 1 failure (despite actually adding the file). Example on 2.47.0:

git init mkdir dir touch dir/file git add dir/file echo dir >.gitignore git add dir/file

The last command fails with exit code 1 and prints:
> The following paths are ignored by one of your .gitignore files:
> dir
> hint: Use -f if you really want to add them.
> hint: Disable this message with "git config advice.addIgnoredFile false"

Suppose we change dir/file before the last command. Then after the last command, the change is in the index, despite what the warning indicates.

- Christian
Next: Johannes Sixt
Message 1 of 3 in “[BUG] spurious failure when adding tracked file in ignored directory”
  1. Christian SattlerOct 25, 2024
  2. Johannes SixtOct 27, 2024
  3. Christian SattlerOct 27, 2024

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.