Ricardo

Git 本地与全局配置笔记

阅读时长: 1 分钟

配置用户名,颜色

代码
1
2
3
git config --global user.name "you_name"  # 设置全局用户名
git config --global user.email "user@example.com"  # 设置全局邮箱
git config --global color.ui true  # 设置全局颜色显示

git 相关配置 https://zhuanlan.zhihu.com/p/133706032

配置全局

Bash
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# git config --global alias.confg 'config --global'  # 目前看似乎没有生效
git config --global alias.st status
git config --global alias.co checkout
git config --global alias.ci commit
git config --global alias.br branch
git config --global alias.unstage 'reset HEAD'
git config --global alias.last 'log -1'
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"
git config --global core.quotepath false  # vscode git status/commit 乱码
# 全局忽略 .DS_Store 文件
# specify a global exclusion list
git config --global core.excludesfile ~/.gitignore
# adding .DS_Store to that list
echo .DS_Store >> ~/.gitignore

配置针对当前仓库

Bash
1
2
git config alias.st status
git config alias.co checkout

生成ssh-key generate

Bash
1
ssh-keygen -t rsa -C 'company name'

本地配置

代码
1
2
git config --local user.name "cxx"
git config --local user.email "sxx"
Licensed under CC BY-NC-SA 4.0
comments powered by Disqus
记录自己
Built with Hugo
主题 Stack 由 Jimmy 设计