We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
标签(空格分隔): git 换行 intellij
下午搞了一下午测试,发现总是在提交的时候提示自动把换行符从lf转换为crlf,真是奇怪,明明把git config --global core.autocrlf 设为false了。 查阅了资料,看到.gitattributes文件里面可以设定对文件换行符的操作,但是那篇文章说的有点矛盾,上面说.gitattributes 文件里面的设置会覆盖掉global的设置,下面给的模板里面的英文说明是没有指定global属性的时候生效。 只能自己做测试了。 0927测试记录
lf
crlf
git config --global core.autocrlf
false
.gitattributes
git reset head^
git reset --hard head^^
添加测试记录:
core.autocrlf == false
但是打砖块的代码切换的时候就总是自动把换行符切换成crlf
还是看看有哪里配置不一样吧。
经过排查,工程文件夹下有一个.gitattributes 的文件,不想挨个排查里面的属性了,直接删除文件,另外执行git rm .gitattributes,提交,这次把文件换行符手动转换成lf然后提交,然后reset,切换branch,终于正常了。
git rm .gitattributes
删除了.gitattributes文件后,intellij和github for windows的切换branch也不会更改换行符了。
所以还是.gitattributes里面的设置可以覆盖全局设置,猜测发挥效果的命令是* text=auto
* text=auto
.gitattributes 文件内容附在结尾。
0927晚上做测试用的是cygwin里面的git
我下午执行git各种命令的时候是用的windows下的gitbash,reset,checkout的时候也是各种错乱,尝试用网上重建index的方法修改repo中的换行设置,但是还是不行。
另外最近刚使用intellij,不知道哪些文件是需要版本控制的,搞的一团糟。
目前gitignore的配置是 .idea *.iml 都不做版本控制,目前切换branch的时候还能正常工作。先这样吧,以后慢慢改。
使用git的时候,进入cygwin,不能在intellij里面做操作。
顺带一提,intellij里面有一个文件是控制文件编码方式的,哪个使用utf-8是在里面注明的,晚上测试的时候发现有的文件一切换branch,编码就变gbk了,在intellij的默认编码设置里面全部改成utf-8就行了。
# Auto detect text files and perform LF normalization * text=auto # Custom for Visual Studio *.cs diff=csharp *.sln merge=union *.csproj merge=union *.vbproj merge=union *.fsproj merge=union *.dbproj merge=union # Standard to msysgit *.doc diff=astextplain *.DOC diff=astextplain *.docx diff=astextplain *.DOCX diff=astextplain *.dot diff=astextplain *.DOT diff=astextplain *.pdf diff=astextplain *.PDF diff=astextplain *.rtf diff=astextplain *.RTF diff=astextplain
https://help.github.com/articles/dealing-with-line-endings/#platform-windows cssmagic/blog#22
The text was updated successfully, but these errors were encountered:
No branches or pull requests
git 之 文件换行符
标签(空格分隔): git 换行 intellij
下午搞了一下午测试,发现总是在提交的时候提示自动把换行符从
lf
转换为crlf
,真是奇怪,明明把git config --global core.autocrlf
设为false
了。查阅了资料,看到
.gitattributes
文件里面可以设定对文件换行符的操作,但是那篇文章说的有点矛盾,上面说.gitattributes
文件里面的设置会覆盖掉global的设置,下面给的模板里面的英文说明是没有指定global属性的时候生效。只能自己做测试了。
0927测试记录
git config --global core.autocrlf
为false
。git reset head^
,发现文件换行符还是lf。git reset --hard head^^
恢复到换行符是lf的commit,换行符是会成lf的。crlf
20150928更新(这次使用windows 下的 git bash)
添加测试记录:
core.autocrlf == false
。lf
换行的txt文件,正常修改,add,commit,新建branch,切换branch。换行符没有变化。crlf
,提交,commit,reset --hard,切换branch。发现commit是什么换行符,切换过去就是什么换行符,只是切换换行符的时候diff表示文件全部被更改。很正常呀。但是打砖块的代码切换的时候就总是自动把换行符切换成crlf
还是看看有哪里配置不一样吧。
经过排查,工程文件夹下有一个.gitattributes 的文件,不想挨个排查里面的属性了,直接删除文件,另外执行
git rm .gitattributes
,提交,这次把文件换行符手动转换成lf
然后提交,然后reset,切换branch,终于正常了。删除了
.gitattributes
文件后,intellij和github for windows的切换branch也不会更改换行符了。所以还是.gitattributes里面的设置可以覆盖全局设置,猜测发挥效果的命令是
* text=auto
.gitattributes 文件内容附在结尾。
注意:
0927晚上做测试用的是cygwin里面的git
我下午执行git各种命令的时候是用的windows下的gitbash,reset,checkout的时候也是各种错乱,尝试用网上重建index的方法修改repo中的换行设置,但是还是不行。
另外最近刚使用intellij,不知道哪些文件是需要版本控制的,搞的一团糟。
目前gitignore的配置是 .idea *.iml 都不做版本控制,目前切换branch的时候还能正常工作。先这样吧,以后慢慢改。
使用git的时候,进入cygwin,不能在intellij里面做操作。
顺带一提,intellij里面有一个文件是控制文件编码方式的,哪个使用utf-8是在里面注明的,晚上测试的时候发现有的文件一切换branch,编码就变gbk了,在intellij的默认编码设置里面全部改成utf-8就行了。
.gitattributes 文件内容
参考:
https://help.github.com/articles/dealing-with-line-endings/#platform-windows
cssmagic/blog#22
The text was updated successfully, but these errors were encountered: