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

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

From
CSChristian Sattler <sattler.christian@gmail.com>
Date
Oct 27, 2024, 14:07 UTC
Message-ID
<CALCpNBoZfugMQuuDoAELxkipZjYdhznJw3XzuxDC6XGYbJ9=AA@mail.gmail.com>
In-Reply-To
<3701837d-d9d3-422e-82f2-567a6f832dca@kdbg.org>
On Sun, 27 Oct 2024 at 14:45, Johannes Sixt <j6t@kdbg.org> wrote:
> I cannot reproduce your claim "despite actually adding the file": the
> file is not added. So, everything works as intended. What does `git
> status` tell after `git add`?
Here is the example with modifications before the add.

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

Output of git status:
Show 7 quoted lines
> On branch main
>
> No commits yet
>
> Changes to be committed:
>   (use "git rm --cached <file>..." to unstage)
> new file:   dir/file
> 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:   dir/file
> Untracked files:
>   (use "git add <file>..." to include in what will be committed)
> .gitignore
git add dir/file  # fails with warning and exit code 1
Output of git status:
Show 7 quoted lines
> On branch main
>
> No commits yet
>
> Changes to be committed:
>   (use "git rm --cached <file>..." to unstage)
> new file:   dir/file
> Untracked files:
>   (use "git add <file>..." to include in what will be committed)
> .gitignore
Previous: Johannes Sixt
Message 3 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.