切换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)"
相关推荐
一条Go1 小时前
OnCall 时段路由:跨午夜、左闭右开与「Local 不是时区」
后端·架构·github
黎羽_16 小时前
《开源 PR 实战》系列(三):22 个 PR 之后,批量提 PR 的打法
开源·github·代码评审·pull request·协作
fthux19 小时前
总想着“忙完再休息”?让 Tick Rest 提醒你,先歇一会儿
开源·github·mac·swift·提醒·消息提醒·tick rest·tick rest for mac·消息提醒app
dong_junshuai20 小时前
每天一个开源项目#156 Astryx:主题编译、异步按钮与源码接管
github
逛逛GitHub1 天前
把你的 AirPods 当鼠标用,这 3 个黑科技 GitHub 开源项目有趣。
github
徐小夕1 天前
开源Vector-Graph-RAG:向量+图谱双引擎,打破纯向量RAG的效果天花板
前端·vue.js·github
GitHub实测笔记1 天前
zoxide 本机实测:一万条记查询中 5.7ms0.10 版 import --from
github
Brookty1 天前
Git与GitHub系统学习|本地Git工作模型:终端与进程、CWD、HEAD/Index/工作树及Git对象
git·github
miofly2 天前
Genie 4新增原生音频,实时世界模型加入声音生成
开源·github
dong_junshuai2 天前
每天一个开源项目#155 MuJoCo:从接触求解到控制时序的物理引擎
github