切换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)"
相关推荐
逛逛GitHub1 天前
翻到2 个 GitHub 开源项目,第 1 个太惊艳了
github
Devlive 开源社区1 天前
技术日报|Python ETL框架Pathway日增1219星登顶GitHub
github
zlbit851 天前
【智能体初体验】初识RAG
github
CoderJia程序员甲1 天前
GitHub 热榜项目 - 日榜(2026-1-5)
ai·开源·大模型·github·ai教程
Jagger_2 天前
如何坚持更新技术博客减少摩擦力复盘
github
微小冷2 天前
Git初步教程
git·github·版本管理·团队协作·git教程
2501_941804322 天前
面向微服务灰度发布与动态配置控制的互联网系统高可用架构与多语言工程实践分享
java·人工智能·github
HelloGitHub2 天前
嫌 AI 写的界面太丑?装上这个开源插件,秒变资深设计师
开源·github
徐小夕2 天前
2025年,第二款创业项目,pxcharts超级表格,最新进展来啦
前端·react.js·github