【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"
相关推荐
Jooolin8 小时前
【编程史】Git是如何诞生的?这可并非计划之中...
linux·git·ai编程
Lw老王要学习13 小时前
VScode 使用 git 提交数据到指定库的完整指南
windows·git·vscode
去旅行、在路上13 小时前
Git & Svn
git·svn
abcnull14 小时前
github中main与master,master无法合并到main
git·github
养意19 小时前
git提交代码和解决冲突修复bug
git·bug
码农黛兮_461 天前
Git 常用命令大全
git
一弓虽1 天前
git 学习
git·学习
疯狂的沙粒2 天前
如何通过git命令查看项目连接的仓库地址?
大数据·git·elasticsearch
qq_254617772 天前
Gerrit+repo管理git仓库,如果本地有新分支不能执行repo sync来同步远程所有修改,会报错
git
π大星星️2 天前
Git分布式版本控制工具
分布式·git