Git tips two

in SCM

软件版本:

1
git version 2.23.0

使用http/https协议代码库地址,有时会出现不能存储密码,每次交互操作都需要输入帐户密码情况:

1
2
3
记住密码(默认15分钟):git config --global credential.helper cache
自己定义时间(一小时后失效):git config credential.helper 'cache --timeout=3600'
永久存储密码:git config --global credential.helper store

行结束符处理:

OS Line Endings Comments
Windows CRLF 每行结尾是 <换行><回车 > ,即 \n\r
Mac OS X LF 每行结尾只有 <换行> ,即 \n
Unix/Linux LF 每行结尾只有 <换行> ,即 \n
Classic macOS CR 每行结尾是 <回车>,即 \r
1
2
3
4
5
6
7
8
9
10
11
排除老Mac系统不讨论,项目组如果不是全Windows环境开发/部署的话,还是要自动处理下行结束符。

# Windows用户执行下面配置命令:
$ git config --global core.autocrlf true # 在提交时自动地把行结束符CRLF转换成LF,而在签出代码时把LF转换成CRLF

# Linux 和 Mac用户执行下面配置命令:(预防代码库已经有CRLF结束符的代码)
$ git config --global core.autocrlf input # 在提交时把CRLF转换成LF,签出时不转换

# 默认配置:
$ git config --global core.autocrlf false # 提交和签出时都不对代码行结束符做转换

Comment and share

  • page 1 of 1
Author's picture

Weilong

    Write something about work-life:

PM


Shenzhen