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

Re: Bug with .gitignore and branch switching

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 17, 2017, 21:23 UTC
Message-ID
<xmqqmvcj61j2.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<CAPUVn2u0Uos2mT5+4ejj8m0okNK6XwerL6ce2miHfhtuEs-ZnQ@mail.gmail.com>
Nevada Sanchez <sanchez.nevada@gmail.com> writes:
> Here's an easy to reproduce bug. It's the only example I know of where
> git legitimately loses data in a way that is unrecoverable,
> unexpected, and without warning.

This is an example of a user explicitly telling git to discard data and git performing as it is told.

There is no "untracked but precious" vs "untracked and expendable" difference in the current system. An untracked file that matches patterns listed in .gitignore is treated as the latter.

When you have an untracked file that .gitignore knows about in the working tree while you are on "feature", if switching to another branch requires to remove that file, the content there is deemed expendable, because the user said so by listing it in .gitignore.

We've discussed the lack of "untracked but precious" class a few times on the list in the past, but I do not recall the topic came up in the recent past. It perhaps is because nobody found that class useful enough so far.

Previous: Nevada SanchezNext: Jonathan Nieder
Message 2 of 8 in “Bug with .gitignore and branch switching”
  1. Nevada SanchezMar 17, 2017
  2. Junio C HamanoMar 17, 2017
  3. Jonathan NiederMar 17, 2017
  4. Junio C HamanoMar 17, 2017
  5. Duy NguyenMar 18, 2017
  6. Stefan BellerMar 17, 2017
  7. Nevada SanchezMar 18, 2017
  8. Jonathan NiederMar 17, 2017

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.