切换github帐号

bash 复制代码
#!/bin/bash

# Get the current GitHub user
current_user=$(git config --global user.name)

if [ "$current_user" == "user1" ]; then
    # Switch to user2
    mv id_rsa id_rsa_user1
    mv id_rsa.pub id_rsa_user1.pub
    mv id_rsa_user2 id_rsa
    mv id_rsa_user2.pub id_rsa.pub

    # Configure Git for user2
    git config --global user.name "user2"
    git config --global user.email "user2@gmail.com"
    echo "Switched to user2"
else
    # Switch to user1
    mv id_rsa id_rsa_user2
    mv id_rsa.pub id_rsa_user2.pub
    mv id_rsa_user1 id_rsa  
    mv id_rsa_user1.pub id_rsa.pub

    # Configure Git for user1
    git config --global user.name "user1"
    git config --global user.email "user1@gmail.com"
    echo "Switched to user1"
fi

# Display the current user name and email
echo "Current GitHub user: $(git config --global user.name)"
echo "Current GitHub email: $(git config --global user.email)"
相关推荐
comcoo6 小时前
龙虾 AI OpenClaw Windows 本地部署,5 分钟落地专属私有化 AI 智能体
github·开源软件·龙虾ai·open claw部署
德宏大魔王(AI自动回关)8 小时前
鱿鱼云码公测:基于YOLOv26+消息队列的高性能打码平台
yolo·github·打码平台·鱿鱼云码
2601_961194029 小时前
2026六级词汇PDF下载|大学英语六级单词表+音频PDF
windows·git·eclipse·pdf·github
xuhe211 小时前
AI时代一届计算机学生本科生 四年生活 保研记录: 四非本科 -> 中流985
ai·github·科研
小橙讲编程12 小时前
一键给 AI Agent 装上「互联网眼睛」:Agent Reach 深度解析与实战指南
人工智能·开源·github·ai编程
无人生还别怕13 小时前
搭建gitlab服务并接入openldap认证
git·gitlab·github·openldap·ldap·统一认证
小二·14 小时前
Python 异步编程深度解析:Async/Await 实战
网络·python·github
C++ 老炮儿的技术栈15 小时前
如何利用 OpenCV 将图像显示在对话框窗口上
c语言·c++·人工智能·qt·opencv·计算机视觉·github
奥利奥夹心脆芙17 小时前
选型与实战:Fluentd 全维对比与指标管道的 AWS ECS 落地
github