【git】修改git凭据

Windows

poweshell 复制代码
# 删除 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

bash 复制代码
#!/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 email

git config --global user.name "$username"
git config --global user.email "$email"

# 清除本地凭据缓存
git config --global credential.helper cache
git config --global --unset credential.helper

echo -e "\033[32mGit 配置已重置,下次push时需要重新输入 GitHub 账号密码\033[0m"
相关推荐
sulikey1 天前
从零配置一个规范的 Python Git 仓库(适用于 Gitee / GitHub)
git·python·pycharm·gitee·github
学渣676561 天前
【面向小白】git rebase全面总结,什么时候用rebase
git
小龙报1 天前
《算法每日一题(1)--- 第31场蓝桥算法挑战赛》
c语言·开发语言·c++·git·算法·学习方法
222you1 天前
idea整合Git
git
今禾2 天前
Git完全指南(下篇):Git高级技巧与问题解决
前端·git·github
Molesidy2 天前
【Git】【TortoiseGit】TortoiseGit安装与基础使用
git
lichong9512 天前
Git 检出到HEAD 再修改提交commit 会消失解决方案
java·前端·git·python·github·大前端·大前端++
222you2 天前
Git仓库推送到GitHub
git·github
你的人类朋友2 天前
hotfix分支的使用
git·gitlab·github
小蜜蜂爱编程2 天前
gerrit的部署与配置关联到不同服务器上的git仓库
运维·服务器·git·gerrit