【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"
相关推荐
真人不梦11 小时前
Lazygit: 从0到熟练使用,你需要的都在这里
git·github
denggun1234515 小时前
图片上传git时压缩
git·ios·objective-c·iphone·xcode
行走的陀螺仪17 小时前
git-旧项目继续开发新功能,同时还要维护线上版本
git·git push·git commit·git 协同开发
fendouweiqian21 小时前
git提交与commitlint规则
git
C.咖.1 天前
Linux环境下——Git 与 GitHub
linux·git·github·远程仓库
杂鱼豆腐人1 天前
pnpm环境下防止误使用npm的方法
前端·git·npm·node.js·git bash
摇滚侠1 天前
GIT版本管理工具轻松入门 | TortoiseGit,Git 介绍软件安装配置,笔记01
笔记·git
山有木兮木有枝_1 天前
“误操作导致 feat 功能未生效,尽管 merge 已完成”
git
百锦再1 天前
第14章 智能指针
android·java·开发语言·git·rust·go·错误
摇滚侠1 天前
GIT版本管理工具轻松入门 | TortoiseGit,解决冲突,笔记07
笔记·git