【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"
相关推荐
b1ng7 小时前
新人程序员 Git 一站式指南
git·github
程序员的世界你不懂8 小时前
IDE 关联 Git 操作
ide·git
weixin_4284984910 小时前
Git Submodule 介绍和使用指南
git
jingshaoqi_ccc21 小时前
GitKraken最后一个免费版本和下载地址
git·github·gitkraken·版本管理工具
乌云暮年21 小时前
Git简单命令
git·gitee·github·batch命令
用户1259265423201 天前
使用 Docker 搭建 Gitea 并实现 Git HTTP 自动登录
git
一只毛驴1 天前
谈谈对git stash的理解?
git
长风破浪会有时呀1 天前
Git 学习笔记
笔记·git·学习
中微子2 天前
Git Rebase 详解:概念、原理与实战示例
git
荔枝吻2 天前
【保姆级喂饭教程】Windows下安装Git Flow
windows·git·git flow