Git的基本配置

设置签名

系统用户级别: 登录当前操作系统的用户范围

git config --global user.name "hglibin"
git config --global user.email [email protected]

信息保存位置:

~/.gitconfig文件

查看命令:

cat ~/.gitconfig

检查配置信息:

git config --list

项目级别/仓库级别: 仅在当前本地库范围内有效

git config user.name "hglibin"
git config user.email [email protected]

信息保存位置:

./.git/config

查看命令:

cat ./.git/config
git config --global user.name
git config --global user.email

级别优先级

  • 就近原则: 项目级别优先于系统用户级别,二者都有时采用项目级别的签名。
  • 如果只有系统用户级别的签名,就以系统用户级别的签名为准。
  • 二者都没有不允许。

生成SSH keys

# 查看本地有没有
cat ~/.ssh/id_rsa.pub
# 若无则生成新的
ssh-keygen -t rsa -C "[email protected]"
# 复制id_rsa.pub里面的key
cat ~/.ssh/id_rsa.pub

配置SSH keys

Github
https://github.com/settings/keys

Gitlab
https://git.lug.ustc.edu.cn/profile/keys

Gitlab.com
https://gitlab.com/profile/keys

测试是否联通

ssh [email protected]
ssh [email protected]
ssh [email protected]

猜你喜欢

转载自www.cnblogs.com/hglibin/p/11876673.html
今日推荐