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

Re: Files modified, even after: git reset --hard

From
Chris Torek <chris.torek@gmail.com>
Date
Jul 26, 2021, 02:59 UTC
Message-ID
<CAPx1GvdM7CzsbT1SWW9+OPcG9FL7WXQ7YD6aM7P0krujp_OrkQ@mail.gmail.com>
In-Reply-To
<070f7f5e-0e6c-2edc-1403-9265c810df17@mfriebe.de>
On Sun, Jul 25, 2021 at 6:34 PM Martin <git@mfriebe.de> wrote:
Show 9 quoted lines
> Actually there is something else.
>
> If a file has line-endings that will change, then
>     git add --renormalize .
>     git commit -m foo
> will commit those files.
>
> But I am now also getting files, that show modified, but that can not be
> committed renormalized (0 lines changed).
I believe (but can't demonstrate) that this is a temporary condition.

Git has a number of cheats to make `git status` and other ops fast. These cheats *assume* that the committed files, the index copies of files, and the working tree copies of files all agree in terms of line endings as coordinated through `core.autocrlf` and `.gitattributes` settings.

When they *don't* agree, you get phantom differences. Running commands like `git diff` show no differences because of these phantom states. Eventually this clears up on its own when the cheats really *do* agree with the settings. Changing the settings is what disturbs the cheats.

Git can't do much with `core.autocrlf`, but if it noticed that a `.gitattributes` file was very recent, and turned off the shortcuts and did the slower full status checks, updates via `.gitattributes` would not show phantom changes. The drawback is that updates to `.gitattributes` could make `git status` very slow.

Overall this isn't normally a big problem. It only affects one person at a time, when they change these settings, and then it clears up over time...

Chris
Previous: MartinNext: Martin
Message 7 of 16 in “Files modified, even after: git reset --hard”
  1. MartinJul 25, 2021
  2. MartinJul 25, 2021
  3. MartinJul 25, 2021
  4. MartinJul 25, 2021
  5. Chris TorekJul 26, 2021
  6. MartinJul 26, 2021
  7. Chris TorekJul 26, 2021
  8. MartinJul 26, 2021
  9. Chris TorekJul 26, 2021
  10. MartinJul 26, 2021
  11. Philip OakleyJul 26, 2021
  12. MartinJul 26, 2021
  13. Chris TorekJul 26, 2021
  14. MartinJul 27, 2021
  15. Philip OakleyJul 26, 2021
  16. MartinJul 26, 2021

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.