Gut*_*Haz 6 windows git line-endings
在 Windows 上,我想查看所有以 LF 行结尾的 linux shell 文件 (.sh)
其他基于文本的文件的行结尾应转换为 CRLF。(通过全局 core.autocrlf=true 处理)
[core]
editor = 'C:/Tools/Notepad++/notepad++.exe' -multiInst -notabbar -nosession -noPlugin
autocrlf = true
*.sh text eol=lf
我git add --renormalize .在添加 .gitattributes 文件时使用。
不幸的是,.sh 文件在签出后仍然有 CRLF。
附加信息:我的一位团队成员确实在一些提交之前更改了他的全局 core.autocrlf=false ,我猜这导致了混乱的行结尾。
通过上述步骤,我至少可以修复本地存储库的文件以再次以 CRLF 结尾。
尝试的步骤:
user@workstation MINGW64 /c/repos/project-source (bug_sh_files_eol_lf)
$ git status
On branch bug_sh_files_eol_lf
Your branch is up to date with 'origin/bug_sh_files_eol_lf'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: production_code/build_production_code.sh
modified: test_code/unit_tests/create_unit_test_xml.sh
no changes added to commit (use "git add" and/or "git commit -a")
user@workstation MINGW64 /c/repos/project-source (bug_sh_files_eol_lf)
$ git add . -u
warning: LF will be replaced by CRLF in production_code/build_production_code.sh.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in test_code/unit_tests/create_unit_test_xml.sh.
The file will have its original line endings in your working directory
user@workstation MINGW64 /c/repos/project-source (bug_sh_files_eol_lf)
$ git status
On branch bug_sh_files_eol_lf
Your branch is up to date with 'origin/bug_sh_files_eol_lf'.
nothing to commit, working tree clean
user@workstation MINGW64 /c/repos/project-source (bug_sh_files_eol_lf)
.gitattributes没关系,我的文件名有一个拼写错误
尽管如此,解决方案:
修复 .gitattributes
# normalize all introduced text files to LF line endings (recognized by git)
* text=auto
# additionally declare text file types
*.sh text eol=lf
*.c text
*.h text
*.txt text
*.yml text
Run Code Online (Sandbox Code Playgroud)
调用git add --renormalize .以修复存储库中带有 CRLF 的文件的行结尾
| 归档时间: |
|
| 查看次数: |
2107 次 |
| 最近记录: |