【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"
相关推荐
梅梅绵绵冰4 小时前
Git分支管理
git
ys~~6 小时前
git学习
git·vscode·python·深度学习·学习·nlp·github
Rysxt_9 小时前
IDEA中Git隐藏更改(Stash)功能详解教程
数据库·git·intellij-idea·stash
Mr-Apple11 小时前
记录一次git commit --amend的误操作
大数据·git·elasticsearch
UVM_ERROR12 小时前
Git仓库损坏(Segmentation fault)修复实战:虚拟机环境下UVM项目救援指南
笔记·git·vscode·github·芯片
j_xxx404_13 小时前
Linux:版本控制器Git(第一章)|历史|理解Git|相关git操作|提交冲突解决
linux·运维·git·ai
牛奔13 小时前
git本地提交后,解决push被拒绝 error: failed to push some refs to
大数据·git·elasticsearch·搜索引擎·全文检索
少年姜太公1 天前
什么?还不知道git cherry pick?
前端·javascript·git
MatrixOrigin1 天前
在数据库里玩“平行宇宙”:MatrixOne Data Branch 让数据也拥有Git 的分支/合并/对比/回滚(含跨集群同步)
git·sql·数据分析
VcB之殇1 天前
git常用操作合集
前端·git