在使用“文本”属性规范化文件后,如何强制 git 检出主分支并删除回车符?

2024-04-04

好的,所以我添加了文件.gitattributes像这样的线条

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

然后我按照以下说明进行操作http://git-scm.com/docs/gitattributes#_checking-out_and_checking-in 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
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

在使用“文本”属性规范化文件后,如何强制 git 检出主分支并删除回车符? 的相关文章

随机推荐