切换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)"
相关推荐
逛逛GitHub5 小时前
民间大神移植《GTA 6》进度已经到 90% 了,这几个 GitHub 项目关注一下
github
解道Jdon7 小时前
Rust重写OpenCode Rune:性能提升最高100倍
ide·windows·git·svn·eclipse·github·visual studio
徐小夕9 小时前
从 RAG 工具到文档处理平台,聊聊 LlamaIndex 为什么成了 AI 应用的标配底座
前端·vue.js·github
jasmine02449 小时前
GitHub 开源背单词游戏:四六级考研词库,拼写正确就能攻击
游戏·github·工具类
钱栈up12 小时前
GitHub 热榜上手|OpenMausBot:一周+7077星的本地 Agent 聊天客户端
typescript·开源·github
秋千易1 天前
同一提交,旧基线红、新基线绿:基线放行了门禁
github
撸码猿1 天前
1Password 后端被入侵:密码库为什么没被拿走
网络安全·github·供应链安全·钓鱼·1password
一条Go1 天前
26 篇之后:Alioth 的 26 个设计决定
后端·github
一条Go1 天前
开源新生代雷达 · 第 25 期
github