git配置

git配置

摘要
根据个人习惯优化git配置。

配置

必配

配置自己的git认证信息,git_usernamegit_useremail替换成自己的用户名和提交邮件地址。方便协同开发。

1
2
git config --global user.name <git_username>
git config --global user.email <git_useremail>

选配

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# 编辑
git config --global core.editor vim # 使用vim编辑,默认Emacs
git config --global core.ignorecase false # 区分文件名大小写
git config --global core.autocrlf false # 换行模式为 input,即提交时转换为LF,检出时不转换
git config --global core.safecrlf true # 拒绝提交包含混合换行符的文件
git config --global core.fileMode false # 忽略文件mode变化,只要代码可以clone,mode就可以修改
git config --global core.longpaths true # 支持超长路径
git config --global core.quotepath false # 支持中文路径
git config --global gui.encoding utf-8 # utf-8编码
git config --global i18n.commitEncoding utf-8
git config --global i18n.logOutputEncoding utf-8
git config --global svn.pathnameencoding utf-8
git config --global merge.tool vimdiff
git config --global mergetool.keepBackup true
git config --global commit.template $HOME/.git_github # git commit提交模板,可以在 ~/.git_github 中添加自定义内容
:> $HOME/.git_github

# 配色
git config --global color.status auto
git config --global color.branch auto
git config --global color.ui auto
git config --global color.diff auto
git config --global color.interactive auto

# 安全认证
git config --global http.sslVerify false
git config --global http.postBuffer 1073741824 # 1GB
git config --global credential.helper store # 缓存认证信息

# 别名
# alias: git st
git config --global alias.st status
# alias: git cm
git config --global alias.cm 'commit -s'
# alias: git lg
git config --global alias.lg "log --color --graph --pretty=format:'%C(bold red)%h%C(reset) - %C(bold green)(%cr)%C(bold blue)<%an>%C(reset) -%C(bold yellow)%d%C(reset) %s'"

手册

参考文章:
无。

Author

gh503

Posted on

2024-04-26

Updated on

2024-07-17

Licensed under