欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 教育 > 培训 > 【git】修改git凭据

【git】修改git凭据

2025/10/20 5:24:07 来源:https://blog.csdn.net/qq_18846849/article/details/144291847  浏览:    关键词:【git】修改git凭据

Windows

# 删除 Windows 凭据
cmdkey /delete:git:https://github.com# 删除本地 git 配置
git config --global --unset user.name
git config --global --unset user.email# 设置新的 git 配置(请修改为你的信息)
git config --global user.name "你的新用户名"
git config --global user.email "你的新邮箱"# 清除 git 缓存的凭据
git config --global --unset credential.helper# 提示完成
Write-Host "Git 配置已重置,下次push时需要重新输入 GitHub 账号密码" -ForegroundColor Green

Linux

#!/bin/bash# 删除缓存的凭据
git config --global --unset credential.helper
rm -rf ~/.git-credentials# 清除 SSH 密钥(可选,取消注释如果需要)
# rm -rf ~/.ssh/id_rsa*# 删除全局 git 配置
git config --global --unset user.name
git config --global --unset user.email# 设置新的 git 配置
echo "请输入你的 Git 用户名:"
read username
echo "请输入你的 Git 邮箱:"
read emailgit config --global user.name "$username"
git config --global user.email "$email"# 清除本地凭据缓存
git config --global credential.helper cache
git config --global --unset credential.helperecho -e "\033[32mGit 配置已重置,下次push时需要重新输入 GitHub 账号密码\033[0m"

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词