git - 在使用 "text"属性规范化文件后,如何强制 git check out 主分支并删除回车符?

标签 git newline core.autocrlf

好的,所以我在文件 .gitattributes 中添加了这样的行

*.css text
*.js text
etc...

然后我按照 http://git-scm.com/docs/gitattributes#_checking-out_and_checking-in 中的说明进行操作

$ rm .git/index     # Remove the index to force Git to
$ git reset         # re-scan the working directory
$ git status        # Show files that will be normalized
$ git add -u
$ git add .gitattributes
$ git commit -m "Introduce end-of-line normalization"

但现在我的工作副本仍然有回车!我有想要保留的未跟踪文件。如何让 git checkout master 分支再次使用标准化文件?

我知道存储库中的文件已规范化,因为当我克隆存储库时,我拥有所有没有回车符的文件。

最佳答案

啊啊啊!检查之前的提交,然后检查主提交。

git checkout HEAD^
git checkout -f master

关于git - 在使用 "text"属性规范化文件后,如何强制 git check out 主分支并删除回车符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17223527/

相关文章:

git - git 中跨分支的等效更改的簿记清理

git ls-remote 返回 "fatal: No remote configured to list refs from."

Windows 批处理 : echo without new line

java - jgitblame 文件的某些行具有 null 提交 shas

windows - 为什么显示 'Updating the Git index failed'

GitHub for Mac 同步删除了我未提交的更改

git - 在 Git 提交之前替换文本文件中的 $markers$

c++ - 如何让 G++ 预处理器在宏中输出换行符?

ios - Swift 字符串中的换行符和/或回车符

带有 autocrlf=true 的 Git 按原样 check out 具有混合行结尾的文件