切换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)"
相关推荐
放飞自我的Coder30 分钟前
【github-action 如何为github action设置secrets/environment】
github·action
绝无仅有1 小时前
编写 Go 项目的 Dockerfile 文件及生成 Docker 镜像
后端·面试·github
绝无仅有1 小时前
使用 Docker 部署 Go 项目(Beego 框架)
后端·面试·github
星哥说事2 小时前
开源轻量级表格革命——用Teable解锁你的数据管理新姿势
github
悟空聊架构3 小时前
从 0 到 1:Jenkins 对接企微机器人避坑指南(附可下载 Pipeline 模板)
后端·架构·github
HelloGitHub4 小时前
直击痛点的开源项目「GitHub 热点速览」
开源·github
超级小忍15 小时前
深入解析 GitHub Actions 工作流文件编写:从入门到实战
github
Haku Coder16 小时前
我的第一个音乐元素浏览项目上传至Github啦!
github
程序媛Dev18 小时前
还在 SSH 连服务器敲 SQL?我用 Sealos 把数据库管理后台搬进了浏览器!
开源·github
猫头虎20 小时前
猫头虎AI分享|一款Coze、Dify类开源AI应用超级智能体Agent快速构建工具:FastbuildAI
人工智能·开源·github·aigc·ai编程·ai写作·ai-native