说明:此处为什么放在开头,因为很多人都不仔细看下面内容,这一句是废话。

        只要是加-- global的都是设置全局的,建议不要这样设置。下面的所有的操作都是编辑的 .git/config的内容,也可以找到这个文件,直接添加内容。

1.配置用户名和邮箱,分为全局和项目两种:

        1)此处内容为全局设置用户名和邮箱 

git config --global user.name "username"
git config --global user.email "useremail@qq.com"

        2)  此处为单个项目设置用户名和密码

git config user.name "username"
git config user.email "useremail@qq.com"

2.清除配置中纪录的用户名和密码,下次提交代码时会让重新输入账号密码

git config --system --unset credential.helper

3.执行下面命令之后,再次pull或push时会缓存输入的用户名和密码

git config --global credential.helper store        #全局
git config credential.helper store        #单个项目

4.清除git缓存中的用户名的密码

git credential-manager uninstall

#如果电脑是macos提示 git: 'credential-wincred' is not a git command. See 'git --help'
#第一步:git config --unset-all credential.helper
#第二步:git config --global credential.helper osxkeychain
Logo

瓜分20万奖金 获得内推名额 丰厚实物奖励 易参与易上手

更多推荐