配置项 - 1684838553/webTips GitHub Wiki
git配置命令
1.列出当前配置
git config --list
2.列出全局配置
git config --global --list
3.配置用户名
git config --global user.name "your name"
4.配置用户邮箱
git config --global user.email "[email protected]"
使用https链接克隆仓库,解决用户名密码的问题
1.清除掉缓存在git中的应户名和密码
git credential-manager uninstall
2.清除掉缓存在git中的用户名和密码后,以后每次用 https 方式拉取代码都需要输入用户名和密码
// 从系统的 Git 配置文件中删除 credential.helper 配置项
git config --system --unset credential.helper
// 将 credential.helper 配置项设置为 store
// 设置该配置项后,输入用户名和密码。凭证将被永久存储在 ~/.git-credentials 文件中
git config --global credential.helper store
这个命令的作用是长期存储密码的。
使用ssh链接克隆仓库
创建ssh公钥
ssh-keygen -t rsa -C "邮箱地址"
生成不带密钥的.ssh, 在要求输入密钥时,直接返回。生成带密钥的.ssh。在要求输入密钥时,输入密钥,并再次确认密钥。
多用户之间的切换
1.新建一个目录,在当前目录下新建一个.my-gitconfig文件,这个文件里面配置用户名和邮箱
[user]
name = 168
email = [email protected]
2.在全局配置中,配置includeif属性
[includeif "gitdir:D:/Study/"]
path = D:/Study/.my-gitconfig
即,在Study目录下面,用的是168账号提交代码