문제

I know that there are tons of articles about this issue. But I'm struggling with it for couple of weeks with no success.

I'm trying to use best practices that are discribed on github. So I added a .gitattributes file, for example it looks like this:

*.cs text

And I've normalized line endings for all files. Now I have clean working copy with nothing to commit. But now if I open a fine in any windows text editor and make some random change, save file, undo that change I see this file as changed. I understand that this is because file now has windows style line endings. But this is horrible way of working, file has no changes and I want git to know about it without git reset --hard. What would you recommend in such case?

도움이 되었습니까?

해결책

If you don't want the eol style of your files changed back to windows, don't ask git to perform any "automagic" transformation.
So, contrary to the "best practices from GitHub":

git config --global core.autocrlf true

If you really (I mean really) need one specific set of files in one specific directory to get a particular eol style, add it in your .gitattributes file within said directory, meaning not using text=auto, only "text eol=lf or crlf"

다른 팁

The real question here is: what are you working on and with whom?

Unless you are doing OSS work, all this attribute confusion is not worth it. For an organization with a team of people, turn automatic line ending conversions off by setting:

core.autocrlf false

This covers the majority of cases out there.

If you have a submodule that is on GitHub, you can set those up on a per repo basis.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top