切换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)"
相关推荐
冬奇Lab4 小时前
一天一个开源项目(第35篇):GitHub Store - 跨平台的 GitHub Releases 应用商店
开源·github·资讯
Jahzo6 小时前
openclaw桌面端体验--ClawX
人工智能·github
逛逛GitHub8 小时前
6个粉丝推荐的 GitHub 项目,收藏一波。
github
MaoPou12 小时前
Hello Haxe篇
github
Bigger15 小时前
为什么你的 Git 提交需要签名?—— Git Commit Signing 完全指南
git·开源·github
慢慢开始吧1 天前
Redmi Note 7 Pro (Violet) 爆改满血 Linux 掌上服务器指南
github
模型时代1 天前
GitHub Codespaces存在RoguePilot漏洞,可致GitHub令牌泄露
github
webkubor1 天前
AI 时代的 robots.txt:深度解析 llms.txt 规范与项目“AI 原生化”改造实战
github
i学长的猫1 天前
obsidian md github站点
github
jack@london1 天前
使用Railway
github