切换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)"
相关推荐
维基框架3 小时前
GitHub源码处理提速 一趟扫描反而更慢
人工智能·github
徐小夕4 小时前
开源!我用SQLite + DuckDB打造了一款可视化AI问数平台
前端·算法·github
码流怪侠7 小时前
SuperAGI 技术深度解析:开发者优先的开源自主 AI Agent 框架
github·agent
dong_junshuai8 小时前
每天一个开源项目#19 多源数据自动报告生成框架
github
vance048 小时前
免费Cloudflare隧道隐藏公网IP
linux·tcp/ip·github
dong_junshuai11 小时前
每天一个开源项目#56 reverse-skill:11K Stars 的安全 Agent 路由器
github
逛逛GitHub11 小时前
3 个最近在 GitHub 上非常火的项目,最后一个有创意。
github
AC赳赳老秦15 小时前
开源组件版本数据监控:OpenClaw 抓取公开版本信息,自动提醒更新与安全风险
前端·python·安全·开源·github·php·openclaw
TunerT_TQ16 小时前
Valhalla 静态工程审阅 #012|Hertz 源码证据驱动评测【大厂开源基础设施特辑】
测试工具·微服务·开源·github·字节跳动·cloudwego·http框架
一次旅行16 小时前
fzf+ripgrep+fd终端三合一实战:一套检索工具链,大幅提升大型项目开发效率
人工智能·python·github