当前位置: 首页 > news >正文

git 的行结束符

  • CR (Carriage Return) 表示<回车>
  • LF (Line Feed) 表示<换行>

1. 不同系统的行结束符

系统名称行结束符意义释义git line endings选项
DOS / Windows\r\nCRLF‘\r’是使光标移动到行首
’\n’是使光标下移一行
Windows-style
MacOS\rCRreturnAs-is
UNIX / Linux\nLFnewlineUnix-style

2. 安装git时的三个选项

在学习git软件,安装git到configuring the line ending conversion时,有三个选项。

a. Checkout Windows-style,commit Unix-style line endings.(签出CRLF,提交签入是LF)

b.Checkout as-is,commit Unix-style line endings.(签出CR,提交签入是LF)

c.Checkout as-is,commit as-is line endings. (签出CR,提交签入是CR)
这里面讲到了做两个操作(Checkout,Commit)的三种处理line endings的操作(Windows-style,Unix-style,As-is)。

3. git软件的 line ending和操作系统的对应关系

  • CRLF->Windows-style

  • LF->Unix Style

  • CR->Mac Style

4. 如何转换git的行尾结束符(line ending)

  • 签入和签出是针对代码管理工具来说的,签出是在本地获取最新代码,签入是将最新代码上传到代码管理工具中
  • 控制git的行尾结束符的是 core.autocrlf 的配置
  • core.autocrlf 的值有三个 true false inout,
    • true: 添加到git仓库时,将把所有CRLF行结尾都变成LF

      If core.autocrlf is set to true, that means that any time you add a file to the git repo that git thinks is a text file, it will turn all CRLF line endings to just LF before it stores it in the commit.。

    • false:不会执行换行转换,按原样签入

      If core.autocrlf is set to false, no line-ending conversion is ever performed, so text files are checked in as-is. This usually works ok。

    • input:添加到git仓库时,将会把CRLF转换成LF。当有人Checkout(签出)代码时还是lf方式。因此在window操作系统下,不要使用这个设置
  • core.autocrlf 三个值的直观变化
    1. true: x -> LF -> CRLF
    2. input: x -> LF -> LF
    3. false: x -> x -> x
      file to commit -> repository -> checked out file
      要提交的文件->存储库->签出的文件

5. git 常用的配置命令

  • git config -l 查看已配置的内容
  • git config --global core.autocrlf true 修改 core.autocrlf 的值,需要在项目的根目录进行修改
http://www.lryc.cn/news/186779.html

相关文章:

  • buuctf PWN warmup_csaw_2016
  • C++中的对象切割(Object slicing)问题
  • VxeTable 表格组件推荐
  • 好消息:用 vue3+layui 共同铸造我们新的项目
  • JS中 split(/s+/) 和 split(‘ ‘)的区别以及split()详细解法,字符串分割正则用法
  • MySQL性能调优
  • 如何解决openal32.dll丢失,有什么办法解决
  • Nginx 如何配置http server 、负载均衡(反向代理)
  • windows docker desktop配置加速地址
  • 戏剧影视设计制作虚拟仿真培训课件提升学生的参与感
  • Transformer预测 | Pytorch实现基于Transformer的锂电池寿命预测(NASA数据集)
  • 取出SQLite数据(基本游标)
  • 信息增益,经验熵和经验条件熵——决策树
  • 手摸手系列之批量修改MySQL数据库所有表中某些字段的类型
  • 视频号直播弹幕采集
  • PostgreSQL ash —— pgsentinel插件 学习与踩坑记录
  • HarmonyOS/OpenHarmony原生应用开发-华为Serverless云端服务支持说明(一)
  • 3分钟基于Chat GPT完成工作中的小程序
  • 使用hugo+github搭建免费个人博客
  • 打印字节流和字符流
  • elementplus下载表格为excel格式
  • 聊聊僵尸进程
  • stm32的时钟、中断的配置(针对寄存器),一些基础知识
  • Vue14 监视属性简写
  • 基于docker+Keepalived+Haproxy高可用前后的分离技术
  • 安装配置deep learning开发环境
  • Docker基础(CentOS 7)
  • HTTP的基本格式
  • Qt元对象系统 day5
  • 【audio】alsa pcm音频路径