【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"
相关推荐
wjs0403 小时前
Git常用的命令
java·git·gitlab
原野风霜3243 小时前
Git使用总结
git
青草地溪水旁3 小时前
Git Bash 中 Git 命令的实用主义指南
git·bash
至善迎风4 小时前
版本管理系统与平台(权威资料核对、深入解析、行业选型与国产平台补充)
git·gitee·gitlab·github·svm
上单带刀不带妹9 小时前
Git rm 命令与系统 rm 命令的区别详解
git
我的收藏手册12 小时前
性能监控shell脚本编写
前端·git·github
Yvonne爱编码14 小时前
简述ajax、node.js、webpack、git
前端·git·ajax·webpack·node.js·visual studio
2501_920047031 天前
git在Linux中的使用
linux·git·elasticsearch
小马哥编程1 天前
DNS解析中的服务器协作机制
服务器·git·github
白帽小野2 天前
SVN和Git两种版本管理系统对比
git·svn·版本控制系统