Git:如何在所有版本的所有文件中重新规范行结尾? [英] Git: how to renormalize line endings in all files in all revisions?

查看:87
本文介绍了Git:如何在所有版本的所有文件中重新规范行结尾?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个现有的存储库,行结尾都是乱码。我想重写整个存储库并彻底修复行结尾。有文本文件和二进制文件,让我们假设git的启发式检测二进制文件将工作得很好。



什么是最简单的方法来重新填充整个存储库文件与规范化(Git 2.16)(2018年第1季度)还有另外一种方式(除了删除索引内容),用 git add --renormalize。 ,这是一种更新更安全的方法来记录您正在纠正行尾约定



请参阅 commit 9472935 (2017年11月16日)通过 TorstenBögershausen( tboegi
(由 Junio C Hamano - gitster -


add :介绍 - renormalize



让它更安全以规范化存储库中的行尾。

使用CRLF提交的文件将使用LF提交。



标准化回购是这样的:

 #确保没有未跟踪的文件
$ echo* text = auto > .gitattributes
$ git read-tree --empty
$ git add。
$ git commit -m引入行尾标准化

用户必须确保没有未跟踪的文件,
,否则将从现在开始添加并跟踪。



新的add --renormalize不会添加未跟踪的文件:

  $ echo* text = auto> .gitattributes 
$ git add --renormalize 。
$ git commit -m引入行尾标准化

请注意 git add --renormalize< pathspec>
git add -u --renormalize< pathspec>



I have an existing repository where line endings are all messed up. I'd like to rewrite the entire repository and fix line endings once and for all. There are text files and binary files, let's assume that git's heuristics for detecting binary files will work just fine.

What's the easiest way to repopulate the entire repository with files with normalized line endings?

解决方案

Since Git 2.16 (Q1 2018) there is another way (other than deleting the index content), with "git add --renormalize .", which is a new and safer way to record the fact that you are correcting the end-of-line convention

See commit 9472935 (16 Nov 2017) by Torsten Bögershausen (tboegi).
(Merged by Junio C Hamano -- gitster -- in commit af6e0fe, 27 Nov 2017)

add: introduce "--renormalize"

Make it safer to normalize the line endings in a repository.
Files that had been committed with CRLF will be committed with LF.

The old way to normalize a repo was like this:

# Make sure that there are not untracked files
 $ echo "* text=auto" >.gitattributes
 $ git read-tree --empty
 $ git add .
 $ git commit -m "Introduce end-of-line normalization"

The user must make sure that there are no untracked files, otherwise they would have been added and tracked from now on.

The new "add --renormalize" does not add untracked files:

$ echo "* text=auto" >.gitattributes
 $ git add --renormalize .
 $ git commit -m "Introduce end-of-line normalization"

Note that "git add --renormalize <pathspec>" is the short form for "git add -u --renormalize <pathspec>".

这篇关于Git:如何在所有版本的所有文件中重新规范行结尾?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆