切换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)"
相关推荐
陌上花开缓缓归以1 小时前
Linux 5.4内核版本内核宏梳理
linux·网络·github
JavaGuide5 小时前
屠榜 GitHub,被迫改名!2026 年最火的 AI 助手 Moltbot
ai·github
CoderJia程序员甲6 小时前
GitHub 热榜项目 - 日榜(2026-01-28)
人工智能·ai·大模型·github·ai教程
极智-9969 小时前
GitHub 热榜项目-日榜精选(2026-01-28)|实用资源与工具、开源LLM应用 | pi-mono、supermemory、mlx-audio等
开源·github·语音处理·密钥管理·llm应用·iptv资源
Lust Dusk10 小时前
如何通过GitHub找到一个人?
安全·网络安全·github
ONLYOFFICE10 小时前
ONLYOFFICE 桌面编辑器正式成为 ShaniOS 默认办公套件
linux·编辑器·github·onlyoffice
独自破碎E10 小时前
如何把本地文件夹和已存在的 GitHub 远程仓库同步
github
嘿吖嘿嘿~10 小时前
怎么解决git@github.com出现Permission denied (publickey)的问题
git·github
独自破碎E10 小时前
CRLF与LF的行分隔符警告⚠️
github
CoderJia程序员甲20 小时前
GitHub 热榜项目 - 日榜(2026-01-27)
github