]> git.ipfire.org Git - thirdparty/git.git/commitdiff
doc: do not use `rm .git/index` when normalizing line endings
authorAndreas Heiduk <asheiduk@gmail.com>
Wed, 14 Jun 2017 06:51:39 +0000 (08:51 +0200)
committerJunio C Hamano <gitster@pobox.com>
Thu, 15 Jun 2017 17:55:47 +0000 (10:55 -0700)
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 <asheiduk@gmail.com>
Helped-by: Junio C Hamano <gitster@pobox.com>
Helped-by: Torsten Bögershausen <tboegi@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/gitattributes.txt

index 4736483865ee56c3cf23f41985e2064fbef0cfea..2a2d7e2a4d2a9cab2af8bd881dd880ca2a52235a 100644 (file)
@@ -229,7 +229,7 @@ From a clean working directory:
 
 -------------------------------------------------
 $ echo "* text=auto" >.gitattributes
-$ rm .git/index     # Remove the index to re-scan the working directory
+$ git read-tree --empty   # Clean index, force re-scan of working directory
 $ git add .
 $ git status        # Show files that will be normalized
 $ git commit -m "Introduce end-of-line normalization"