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

Re: ignored file can be deleted silently

From
Junio C Hamano <gitster@pobox.com>
Date
May 5, 2011, 16:49 UTC
Message-ID
<7viptp9jos.fsf@alter.siamese.dyndns.org>
In-Reply-To
<BANLkTi=C4pO83mT3pO0B_AMaK3RMOC4V8g@mail.gmail.com>
Nguyen Thai Ngoc Duy <pclouds@gmail.com> writes:
> This is on purpose. Commit f8a9d42 (read-tree: further loosen "working
> file will be lost" check. - 2006-12-04) allowed ignored files to be
> overwritten. Perhaps we can have a config to tighten the check again?

No. The real issue is that we have only two classes of paths. Either ignored or unignored.

If we see an unignored path not yet tracked, we notice and suggest "that file might be something valuable and you may forgot to add" in "status" output. In that sense, "unignored" is a synonym of "worth keeping".

Most of the time, "ignored" is also the same as "can be safely discarded" (think: *.o files that can be recreated). If you do not allow them to be discarded, switching from a branch that has "builtin/hello.c" and leaves an ignored compilation artifact "builtin/hello.o" to another branch that did not have "builtin/" directory (probably it is "builtin-hello.c" on that branch), or even worse, a plain text file "builtin", would stop and get you into a horrible habit of constantly saying "checkout -f". Even though there may be cases where there are some files that are not tracked, that you may not want to add, but you may still want to keep, because we have only two ignored/unignored classes, that is how we have done things.

If you really want to fix this to everybody's satisfaction, you need to introduce the third class, ignored-but-precious (IIRC, tla had such a concept), and treat them as "not worth nagging about potentially forgotten as an add target" but still "not automatically nukeable".

Previous: Nguyen Thai Ngoc DuyNext: Daniele Segato
Message 3 of 4 in “ignored file can be deleted silently”
  1. Daniele SegatoMay 5, 2011
  2. Nguyen Thai Ngoc DuyMay 5, 2011
  3. Junio C HamanoMay 5, 2011
  4. Daniele SegatoMay 5, 2011

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.