mirror of
https://github.com/tldr-pages/tldr.git
synced 2025-03-28 21:16:20 +01:00
.gitattributes: specify eol as LF (#9892)
This commit is contained in:
parent
34e23384e7
commit
16d7c72f7c
2 changed files with 2 additions and 34 deletions
7
.gitattributes
vendored
7
.gitattributes
vendored
|
@ -1,8 +1,5 @@
|
|||
# This ensures that the line endings in any files added or modified are
|
||||
# normalized before being committed. On Windows they will automatically
|
||||
# be checked-out as CRLF, and re-converted to LF before check-in.
|
||||
# See https://git-scm.com/docs/gitattributes for more information.
|
||||
* text=auto
|
||||
# https://github.com/tldr-pages/tldr/issues/7097
|
||||
* text=auto eol=lf
|
||||
|
||||
# GitHub linguist ignores markdown files by default, but tldr-pages
|
||||
# is mostly markdown, so we explicitly make the pages detectable
|
||||
|
|
|
@ -90,32 +90,3 @@ git push --force-with-lease
|
|||
```
|
||||
|
||||
[](https://asciinema.org/a/fFMZzQOgJyfUf8HTnXyRj0v02)
|
||||
|
||||
# Editorconfig and Windows
|
||||
|
||||
There is an issue that could arise when you clone the repository under Windows and use an editor which honors the settings in the `.editorconfig` file. With the default configuration, when you initially clone the repository, Git checks out files converting line endings to `CRLF`. Later, when you edit some file, or just save it without any modifications, your editor converts line endings to `LF` as per configuration in the `.editorconfig`. This causes the confusion, making Git mark the files as modified whereas they are not and issue the following warnings on `git diff` and `git add`:
|
||||
|
||||
```
|
||||
warning: LF will be replaced by CRLF in...
|
||||
```
|
||||
|
||||
To handle this problem, you need to clone the repository using the command:
|
||||
|
||||
```sh
|
||||
git clone --config core.eol=lf {{remote_repository_location}}
|
||||
```
|
||||
|
||||
If you've already cloned the repository, and don't want to repeat the whole process (if, for example, you've already made some modifications), you can fix the issue using the following commands. Be careful as these commands are potentially dangerous and you can lose your unfinished work in the current repository!
|
||||
|
||||
```sh
|
||||
# set line feed (LF) as end of line
|
||||
git config --local core.eol lf
|
||||
# stash any local changes (if the working tree is clean, skip this step and the last one)
|
||||
git stash push
|
||||
# remove all the files under version control from index
|
||||
git rm -rfq --cached .
|
||||
# update all the files in index and working tree without converting LF to CRLF, as per new option value
|
||||
git reset --hard HEAD
|
||||
# restore the previous state from stash
|
||||
git stash pop --index
|
||||
```
|
||||
|
|
Loading…
Add table
Reference in a new issue