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?
1 Answers
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' {} +
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.
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
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.

- 37,289
- 4
- 68
- 81

- 224,562
- 31
- 268
- 324