【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 小时前
GitHub/Git 常用命令及使用场景
git·github
慧都小项1 天前
MyEclipse Inline Diff 实用指南:逐处核对 AI 修改再提交
git·ai编程·myeclipse·java 代码审查·ai 代码修改
德育处主任2 天前
让 Claude Code 在你睡觉时接着干活:tmux、权限策略与验收清单
git·ai编程·命令行
为思念酝酿的痛4 天前
Git基本操作
git·github
wno7045 天前
常用的Git命令清单
大数据·git·elasticsearch
真上帝的左手5 天前
3. 代码管理-Git-进阶
git·源代码管理
YIN_尹6 天前
【git原理与使用】git基本操作及底层原理(二)
大数据·git·elasticsearch
程序员爱德华6 天前
Git 命令
git
Cry丶6 天前
Git Rebase 操作备忘
git·rebase
你叶不叶7 天前
abap git 如何从 gitee上在线拉取数据(上一步已经配置好证书)
git·gitee·sap·abapgit