git and svn 行尾风格配置强制为lf

本文介绍了如何通过Git的命令行接口(CLI)和图形界面配置,管理提交和检出时的行尾格式(CRLF和LF),以及如何在TortoiseSVN中设置文件类型的自动换行风格。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

git

CLI配置:

// 提交时转换为LF,检出时转换为CRLF
git config --global core.autocrlf true   

// 提交时转换为LF,检出时不转换
git config --global core.autocrlf input   

// 提交检出均不转换
git config --global core.autocrlf false

CLI查询:

git config --global -l


图形配置:

进入setting, 点git

 .gitconfig 增加如下部分

[core]
	autocrlf = input

svn

svn:eol-style

  • LF: Set end-of-lines automatically to Unix line endings upon checkout and commit.
  • CRLF: Set end-of-lines automatically to Windows line endings upon checkout and commit.
  • native: This will store line endings upon commit to Unix line endings (LF), but will checkout the line endings with either LF or CRLF based upon the client.

图形配置实例:

win11 :  TortoiseSVN setting

默认有# enable-auto-props = yes,放开#号,并增加对应的你使用的文件配置

enable-auto-props = yes
# Add these for each text file type that you use:
*.txt = svn:eol-style=native
*.cs = svn:eol-style=native
*.xml = svn:eol-style=native
*.c = svn:eol-style=native
*.h = svn:eol-style=native
Makefile = svn:eol-style=native

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值