如何消除autocrlf的损坏? [英] How to undo the damage of autocrlf?
问题描述
一段时间以来,我一直在使用autocrlf设置为true的git.我一直在通过cygwin和git-svn一起使用它.它一直给我带来很多问题,我在此处和此处,我应该把它关掉.如何才能消除"主干之间的损坏?
I've been using git with autocrlf set to true for a while. I've been using it with git-svn through cygwin. It's been causing me a bunch of problems and I see here and here that I should probably turn it off. How can I "undo the damage" between trunk and master?
推荐答案
如果您只想在一次提交中修复它,然后不理会它,则可以执行以下操作:
If you just want to fix it in a single commit and then leave it alone, you could do something like:
find . -not \( -path ./.git -prune \) -type f -exec sed -i -e 's/\r//g' {} +
注意:这将从存储库中每个文件中的CR删除.在-type f
之后添加-name '*.someext'
或其他子句以调整查找范围.
Note: This will remove CRs from every file in the repository. Add -name '*.someext'
or other clauses after -type f
to adjust the find's extent.
如果要编辑先前的提交(请注意,这会破坏其他试图将其更改合并到分支中的人!),则可以使用git filter-branch
-编写与上述find
调用类似的脚本,然后使用类似的
If you want to edit prior commits (note that this will break other people trying to merge their changes into your branch!), you can use git filter-branch
- write a script that does something similar to the find
invocation above, then pass it in with something like
git filter-branch --tree-filter /full/path/to/myscript.sh master otherbranch
这将重写历史记录,从而消除源代码存储库中曾经存在的任何CR.请注意,如果您在git-svn创建的所有提交中运行它,可能会破坏git-svn.您可以使用trunk..mylocalbranch
之类的方法仅在本地提交上运行它.
This will rewrite history, eliminating any CR that has ever been in the source code repository. Note that this will likely break git-svn if you run it across any commits created by git-svn. You can use something like trunk..mylocalbranch
to only run it on local commits.
这篇关于如何消除autocrlf的损坏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!