last modified by zhoutianju , 2023-06-02 00:54:42

全局配置

git config 命令使用方法

# 全局作用域设置 x.y.z 的值
git config --global x.y.z 'value'

# 全局作用域查看 x.y.z 的值
git config --global x.y.z

# 全局作用域重置 x.y.z 的值
git config --global --unset x.y.z

# 当前代码库作用域下设置 x.y.z
git config x.y.z 'value'

设置代理

git config --global http.proxy http://127.0.0.1:7890
git config --global https.proxy http://127.0.0.1:7890

支持中文编码

git config --global core.quotepath false
git config --global gui.encoding utf-8
git config --global i18n.commit.encoding utf-8
git config --global i18n.logoutputencoding utf-8

# bash 环境下
export LESSCHARSET=utf-8

# cmd 环境下
set LESSCHARSET=utf-8 # cmd

配置默认的 difftool、mergetool 为 beyond compare

git config --global merge.tool bc3
git config --global mergetool.bc3.path "c:/Program Files/Beyond Compare 4/bcomp.exe"
git config --global diff.tool bc3
git config --global difftool.bc3.path "c:/Program Files/Beyond Compare 3/bcomp.exe"

配置 mergetool 不产生 *.orig 文件

git config --global mergetool.keepBackup false

配置全局用户名、邮箱

git config --global user.name "zhoutianju"
git config --global user.email "tianju.zhou@gmail.com"

配置 lg 子命令别名(优化日志显示)

git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"

换行符

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

# 拒绝提交包含混合换行符的文件
git config --global core.safecrlf true

设置全局忽略

git config --global core.excludesfile .gitignore_global
vi ~/.gitignore_global

.gitignore_global:

# Compiled class file
*.class

# Maven
target/

# IntelliJ project files
*.iml
*.iws
*.ipr
.idea/

# eclipse project file
.settings/
.classpath
.project

# Log file
*.log

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*



Copyright © 2023 zhoutianju.
All rights reserved.

results matching ""

    No results matching ""