I've received files from a collaborator by manual transfer i.e. not from a git way - not from a merge request - that I want to put into my worktree. My issue is that:
- the eol characters don't respect my policy, which is:
- CRLF for most file formats in the working directory;
- LF in the local and remote repositories.
- there are thousands of such files, with a huge majority having only these eol differences, and less than a hundred having meaningful differences.
Here is what I tried:
- I have tried different git settings:
git config --get core.autocrlf=true
to have CRLF in the working directory and LF in local & remote repositories as explained in Git replacing LF with CRLF and I have done renormalization andgit rm --cached -r .
andgit reset --hard
afterwards;- setting the .gitattributes to this template one with additional C# settings and
eol=crlf
to be extra sure these settings aren't lost later as explained in What's the strategy for handling CRLF (carriage return, line feed) with Git? - but fundamentally this adds nothing to the previous point; whitespace = cr-at-eol
so thatgit diff
ignores differences on eol characters as explained in this answer to Make 'git diff' ignore ^M.
- but then my git GUI client SourceTree ignores these settings and still list thousands of file changes. It is able to not show differences, but will still list the file as shown in Force SourceTree ignore line endings in git files. So I've tried several others and I've found no setting in which files with only eol character changes are skipped: SourceTree, SmartGit, Gittyup, GitHub Desktop, GitAhead, TortoiseGit, GitGUI, Git Extensions. GitAhead is the best in that particular instance because it collapses the files with only eol character differences in the list of file differences. But it still lists them, and it is in general very slow.
Here are the strategies that I see:
- Manually reviewing all of the files - I'd rather not;
- Finding a git GUI client that skips files with only eol character differences;
- Replacing all the LF by CRLF using e.g. Notepad++ on the appropriate file formats;
- Creating a branch in which I add the thousands of files, then merging it into my development branch, forcing in the process all the eol characters to be LF in the local & remote repositories.
Any better idea?
Of course, next time I have to do that I'll encourage my collaborator to use git to send me files!