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

Files modified, even after: git reset --hard

From
MMartin <git@mfriebe.de>
Date
Jul 25, 2021, 15:04 UTC
Message-ID
<dd4aca2c-9ca2-e489-d78f-9d2a5580f1a5@mfriebe.de>
I have some files, that will show up modified. Always.

If I just switch to a commit, with clean worktree before, then those files will be modified.

I can not stash them. git reset --hard does not change anything.

Diff shows the entire file is modified. I suspect its the line endings..
This happens on windows, and
   autocrlf=true

The checked out file (which is marked as modified) has the correct CrLf endings.

What I have not been able to find, is what line endings are stored in the blob. Its an xml file, so they should be just Lf. But I *suspect* that the blob contains either CrLf, or mixed line-endings.

Could that be? that if a file does have unexpected line endings in the commit's blob, that it shows as modified?

One the one hand, yes, If I commit, that file will change. On the other hand, if I just check out (or do reset-hard) then I don't expect modified files....

So what should happen?

This also causes problems, because in order to for example rebase something, I first need to switch to some commit that can be checked out without modified files. Or rebase will not work.

Also in that repro, I had problems that some rebases failed with (with 
and without --reapply-cherry-picks)
    error: add_cacheinfo failed
Those rebase where between an orphaned branch, and a "normal" branch.
And it is possible that the file only had the line ending issues in one 
of the 2 branches....
But that I was not able to further investigate.

//git for windows git version 2.32.0.windows.2

Next: Martin
Message 1 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.