Jas*_*son 89 git newline core.autocrlf
好的,所以我.gitattributes
用这样的行添加了文件
*.css text
*.js text
etc...
Run Code Online (Sandbox Code Playgroud)
然后我按照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"
Run Code Online (Sandbox Code Playgroud)
但是现在我的工作副本仍然有回车!我有未跟踪的文件,我想保留.如何使用规范化文件再次git checkout master分支?
我知道文件在存储库中是规范化的,因为当我克隆repo时,我有所有没有回车符的文件.
Jas*_*son 244
啊啊!签出上一次提交,然后签出主人.
git checkout HEAD^
git checkout -f master
Run Code Online (Sandbox Code Playgroud)
mec*_*sin 13
正如其他人指出的那样,可以删除仓库中的所有文件,然后检查它们.我更喜欢这种方法,可以使用下面的代码完成
git ls-files -z | xargs -0 rm
git checkout -- .
Run Code Online (Sandbox Code Playgroud)
或一行
git ls-files -z | xargs -0 rm ; git checkout -- .
Run Code Online (Sandbox Code Playgroud)
我一直都在使用它,还没有发现任何不足之处!
为了进一步解释,在-z
每个条目输出的末尾附加一个空字符ls-files
,并-0
告诉xargs
它分隔它们由那些空字符接收的输出.
归档时间: |
|
查看次数: |
230656 次 |
最近记录: |