repo 在 Github 上,本地是 macOS,改了几个字,diff 结果为啥会出现^M? 这个问题困扰很久了。
git diff app.rb diff --git a/app.rb b/app.rb index fbf9bf3..afa8fd2 100755 --- a/app.rb +++ b/app.rb @@ -85,9 +85,10 @@ Cuba.define do target end end + res.headers['Access-Control-Allow-Origin'] = '*'^M end
git version 2.1.4 @ macOS 10.12.6 git 未设置 core.eol ,也未设置 core.autocrlf
![]() | 1 okletswin 2018-01-12 14:08:52 +08:00 windows 的\n\r |
2 Arnie97 2018-01-12 14:10:12 +08:00 via Android 在你修改之前,版本库里的这个文件就已经是 CRLF 换行了。 |
![]() | 3 zo 2018-01-12 14:28:37 +08:00 如果是在 windows 下开发的话,会有回车换行的问题,表现在 git 上就是^M 了。 当然 git 有个不是那么好用的智能转换,google 搜索 autocrlf 关键字,就可以看到为啥了。 可以这样关掉: git config --global core.autocrlf false git config --global core.safecrlf false |
![]() | 5 sutra 2018-01-12 16:23:34 +08:00 ![]() ^M 是 \r 即回车键。 脱字符表示法( Caret notation )是对 ASCII 码不可打印的控制字符的一种表示法。用一个脱字符 (^)后跟一个大写字符来表示一个控制字符的 ASCII 码值。 https://zh.wikipedia.org/wiki/%E8%84%B1%E5%AD%97%E7%AC%A6%E8%A1%A8%E7%A4%BA%E6%B3%95 |
![]() | 7 lawfun 2018-01-12 21:21:32 +08:00 via Android 我是加的 autocrlf true,然后 git diff 看不到 ^m 了,但是 git clone 其他代码时 会自动加 ^m 了,然后就会有问题了。 |
![]() | 8 suspended OP |