V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
• 请不要在回答技术问题时复制粘贴 AI 生成的内容
maga
V2EX  ›  程序员

mac, linux 上使用 git 烦人的^M 问题

  •  
  •   maga · Jul 8, 2014 · 8264 views
    This topic created in 4322 days ago, the information mentioned may be changed or developed.
    广大V友有没有同时在mac, linux上使用git遇到烦人的^M问题,
    我设置git config --global core.autocrlf true, 每次提交都有waring说要显式转换成crlf, 也很烦人。不知道有没有好的办法没有?
    16 replies    2014-07-08 09:39:33 +08:00
    hanai
        1
    hanai  
       Jul 8, 2014
    木有碰到,编辑器的问题?
    yangqi
        2
    yangqi  
       Jul 8, 2014
    这个应该在编辑器端自动解决掉
    47jm9ozp
        3
    47jm9ozp  
       Jul 8, 2014
    dos2unix
    ?
    dorentus
        4
    dorentus  
       Jul 8, 2014 via iPad   ❤️ 1
    https://help.github.com/articles/dealing-with-line-endings
    正常情况下,在非 windows 系统下不要把它设成 true。
    maga
        5
    maga  
    OP
       Jul 8, 2014
    @yangqi 我用mac 下的vim
    maga
        6
    maga  
    OP
       Jul 8, 2014
    @yangqi 与linux服务器下的vim
    maga
        7
    maga  
    OP
       Jul 8, 2014
    unix LF only (each line ends with an LF character).
    dos CRLF (each line ends with two characters, CR then LF).
    mac CR only (each line ends with a CR character).

    CR = ^M
    maga
        8
    maga  
    OP
       Jul 8, 2014
    而且是多人协作,有些人用windows, 不能强制每个人用同样的编辑器同样的设置。
    dorentus
        9
    dorentus  
       Jul 8, 2014 via iPad
    Mac 十多年前就不是 CR 了,现在是 LF。
    chloerei
        10
    chloerei  
       Jul 8, 2014   ❤️ 1
    @maga 就是要强制。
    chloerei
        11
    chloerei  
       Jul 8, 2014   ❤️ 1
    @maga 不同的编辑器相同的规范。
    williamx
        12
    williamx  
       Jul 8, 2014 via iPhone   ❤️ 1
    @maga 如果换行符对项目有影响,运行dos2unix把所有文件更新一下,如果没啥影响,把设置改为false,就不要纠结了。
    lightening
        13
    lightening  
       Jul 8, 2014
    @maga Mac OS 9 之前才用 CR,现在早就换成 UNIX 的 LF 了。
    vietor
        14
    vietor  
       Jul 8, 2014
    眼不见心不烦——遇到^M基本上都是合并出冲突的时候,每次都沿用文件之前的换行符。
    yangg
        15
    yangg  
       Jul 8, 2014   ❤️ 1
    superbear
        16
    superbear  
       Jul 8, 2014
    在mac或Linux下开发提交就不会出现这种情况吧
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5764 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 68ms · UTC 06:51 · PVG 14:51 · LAX 23:51 · JFK 02:51
    ♥ Do have faith in what you're doing.