Skip to content

Commit 773a889

Browse files
asheidukgitster
authored andcommitted
doc: do not use rm .git/index when normalizing line endings
When illustrating how to normalize the line endings, the documentation in gitattributes tells the user to `rm .git/index`. This is incorrect for two reasons: - Users shouldn't be instructed to mess around with the internal implementation of Git using raw file system tools like `rm`. - Within a submodule or an additional working tree `.git` is just a file containing a `gitdir: <path>` pointer into the real `.git` directory. Therefore `rm .git/index` does not work. The purpose of the `rm .git/index` instruction is to remove all entries from the index without touching the working tree. The way to do this with Git is to use `read-tree --empty`. Signed-off-by: Andreas Heiduk <[email protected]> Helped-by: Junio C Hamano <[email protected]> Helped-by: Torsten Bögershausen <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent fd99e2b commit 773a889

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Documentation/gitattributes.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ From a clean working directory:
229229

230230
-------------------------------------------------
231231
$ echo "* text=auto" >.gitattributes
232-
$ rm .git/index # Remove the index to re-scan the working directory
232+
$ git read-tree --empty # Clean index, force re-scan of working directory
233233
$ git add .
234234
$ git status # Show files that will be normalized
235235
$ git commit -m "Introduce end-of-line normalization"

0 commit comments

Comments
 (0)