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

[PATCH v2 3/3] docs: explain how to deal with files that are always modified

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
Sep 20, 2020, 23:22 UTC
Message-ID
<20200920232231.1300394-4-sandals@crustytoothpaste.net>
In-Reply-To
<20200920232231.1300394-1-sandals@crustytoothpaste.net>

Users frequently have problems where two filenames differ only in case, causing one of those files to show up consistently as being modified. Let's add a FAQ entry that explains how to deal with that.

In addition, let's explain another common case where files are consistently modified, which is when files using a smudge or clean filter have not been run through that filter. Explain the way to fix this as well.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 Documentation/gitfaq.txt | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)
diff --git a/Documentation/gitfaq.txt b/Documentation/gitfaq.txt
index 176b097cf7..afdaeab850 100644
--- a/Documentation/gitfaq.txt
+++ b/Documentation/gitfaq.txt
@@ -363,6 +363,39 @@ information about how to configure files as text or binary.
 You can also control this behavior with the `core.whitespace` setting if you
 don't wish to remove the carriage returns from your line endings.
 
+[[always-modified-files-case]]
+Why do I have a file that's always modified?::
+	Internally, Git always stores file names as sequences of bytes and doesn't
+	perform any encoding or case folding.  However, Windows and macOS by default
+	both perform case folding on file names.  As a result, it's possible to end up
+	with multiple files or directories whose names differ only in case.  Git can
+	handle this just fine, but the file system can store only one of these files,
+	so when Git reads the other file to see its contents, it looks modified.
++
+It's best to remove one of the files such that you only have one file.  You can
+do this with commands like the following (assuming two files `AFile.txt` and
+`afile.txt`) on an otherwise clean working tree:
++
+----
+$ git rm --cached AFile.txt
+$ git commit -m 'Remove files conflicting in case'
+$ git checkout .
+----
++
+This avoids touching the disk, but removes the additional file.  Your project
+may prefer to adopt a naming convention, such as all-lowercase names, to avoid
+this problem from occurring again; such a convention can be checked using a
+`pre-receive` hook or as part of a continuous integration (CI) system.
++
+It is also possible for perpetually modified files to occur on any platform if a
+smudge or clean filter is in use on your system but a file was previously
+committed without running the smudge or clean filter.  To fix this, run the
+following on an otherwise clean working tree:
++
+----
+$ git add --renormalize .
+----
+
 [[recommended-storage-settings]]
 What's the recommended way to store files in Git?::
 	While Git can store and handle any file of any type, there are some
Previous: brian m. carlson
Message 13 of 13 in “FAQ entries for merges and modified files”
  1. 0/3 FAQ entries for merges and modified filesbrian m. carlson, Sep 12, 2020
  2. 3/3 docs: explain how to deal with files that are always modifiedbrian m. carlson, Sep 12, 2020
  3. Martin ÅgrenSep 13, 2020
  4. 2/3 docs: explain why reverts are not always applied on mergebrian m. carlson, Sep 12, 2020
  5. Martin ÅgrenSep 13, 2020
  6. 1/3 docs: explain why squash merges are broken with long-running branchesbrian m. carlson, Sep 12, 2020
  7. Martin ÅgrenSep 13, 2020
  8. brian m. carlsonSep 13, 2020
  9. Junio C HamanoSep 12, 2020
  10. 0/3 FAQ entries for merges and modified filesbrian m. carlson, Sep 20, 2020
  11. 2/3 docs: explain why reverts are not always applied on mergebrian m. carlson, Sep 20, 2020
  12. 1/3 docs: explain why squash merges are broken with long-running branchesbrian m. carlson, Sep 20, 2020
  13. 3/3 docs: explain how to deal with files that are always modifiedbrian m. carlson, Sep 20, 2020

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.