{"id":31375950,"url":"https://github.com/thedevopsblueprint/github-account-switch-cli","last_synced_at":"2026-05-04T09:31:55.119Z","repository":{"id":315736031,"uuid":"1060655992","full_name":"TheDevOpsBlueprint/github-account-switch-cli","owner":"TheDevOpsBlueprint","description":"A fast, reliable cli tool for managing multiple GitHub accounts.","archived":false,"fork":false,"pushed_at":"2025-09-20T12:00:32.000Z","size":30,"stargazers_count":1,"open_issues_count":4,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-20T12:27:02.792Z","etag":null,"topics":["bash-scripting","github","github-config","hacktoberfest","hacktoberfest2025","linux","macos"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TheDevOpsBlueprint.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-20T10:20:39.000Z","updated_at":"2025-09-20T12:26:25.000Z","dependencies_parsed_at":"2025-09-20T12:27:07.347Z","dependency_job_id":"af216ff1-ac7a-43d6-aa1b-bcb089e4cf84","html_url":"https://github.com/TheDevOpsBlueprint/github-account-switch-cli","commit_stats":null,"previous_names":["thedevopsblueprint/gh-acc-switch-cli"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/TheDevOpsBlueprint/github-account-switch-cli","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheDevOpsBlueprint%2Fgithub-account-switch-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheDevOpsBlueprint%2Fgithub-account-switch-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheDevOpsBlueprint%2Fgithub-account-switch-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheDevOpsBlueprint%2Fgithub-account-switch-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TheDevOpsBlueprint","download_url":"https://codeload.github.com/TheDevOpsBlueprint/github-account-switch-cli/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheDevOpsBlueprint%2Fgithub-account-switch-cli/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":277318707,"owners_count":25798184,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-28T02:00:08.834Z","response_time":79,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bash-scripting","github","github-config","hacktoberfest","hacktoberfest2025","linux","macos"],"created_at":"2025-09-28T02:52:24.774Z","updated_at":"2025-09-28T02:52:26.003Z","avatar_url":"https://github.com/TheDevOpsBlueprint.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gh-switch - GitHub Account Switcher 🔄\n\nA fast, reliable command-line tool for managing multiple GitHub accounts. Switch between personal, work, and other GitHub identities seamlessly without manual SSH or Git config editing.\n\n![Shell](https://img.shields.io/badge/shell-bash-green.svg)\n![License](https://img.shields.io/badge/license-MIT-blue.svg)\n![Platform](https://img.shields.io/badge/platform-macOS%20%7C%20Linux-lightgrey.svg)\n\n## ✨ Features\n\n- **Instant Switching**: Change GitHub accounts with a single command\n- **SSH Key Management**: Automatically configures SSH hosts for each profile\n- **Git Config Integration**: Updates user.name and user.email per repository\n- **Profile Storage**: Securely stores multiple account profiles\n- **Auto-Detection**: Automatically detects and switches profiles based on repository\n- **Remote URL Updates**: Automatically updates git remote URLs when switching\n- **No Dependencies**: Pure shell script - works everywhere\n- **Backup Safety**: Automatically backs up SSH config before modifications\n\n## 🚀 Quick Start\n\n### Installation\n\n#### Method 1: Direct Installation (Recommended)\n\n```bash\n# Download and install\ncurl -sSL https://raw.githubusercontent.com/TheDevOpsBlueprint/gh-switch/main/bin/gh-switch-standalone -o /tmp/gh-switch\nchmod +x /tmp/gh-switch\nsudo mv /tmp/gh-switch /usr/local/bin/gh-switch\n\n# Verify installation\ngh-switch --version\n```\n\n#### Method 2: From Source\n\n```bash\n# Clone the repository\ngit clone https://github.com/TheDevOpsBlueprint/gh-switch.git\ncd gh-switch\n\n# Install\nchmod +x bin/gh-switch-standalone\nsudo cp bin/gh-switch-standalone /usr/local/bin/gh-switch\n\n# Verify\ngh-switch --version\n```\n\n#### Method 3: Using Make\n\n```bash\n# Clone and install\ngit clone https://github.com/TheDevOpsBlueprint/gh-switch.git\ncd gh-switch\nmake install\n```\n\n### Initial Setup\n\n```bash\n# Initialize gh-switch\ngh-switch init\n\n# Add your first profile (personal)\ngh-switch add personal\n\n# Add a work profile\ngh-switch add work\n```\n\n## 📖 Usage Guide\n\n### Managing Profiles\n\n#### Adding a Profile\n\n```bash\n# Add a new profile interactively\ngh-switch add personal\n\n# You'll be prompted for:\n# - SSH key path: ~/.ssh/id_ed25519_personal\n# - Git name: John Doe\n# - Git email: john@personal.com\n# - GitHub username: johndoe\n```\n\n#### Listing Profiles\n\n```bash\n# Show all profiles\ngh-switch list\n\n# Output:\n# Available profiles:\n# ==================\n# * personal (active)\n#     User: John Doe\n#     Email: john@personal.com\n#   \n#   work\n#     User: John Smith\n#     Email: john.smith@company.com\n```\n\n#### Switching Profiles\n\n```bash\n# Switch profile for current repository\ngh-switch use work\n\n# Switch globally (all new repos)\ngh-switch use personal --global\n\n# Check current profile\ngh-switch current\n```\n\n### Working with Repositories\n\n#### Cloning with Specific Profile\n\n```bash\n# Use personal profile for personal projects\ngh-switch use personal\ngit clone git@github.com-personal:johndoe/my-project.git\n\n# Use work profile for work projects\ngh-switch use work\ngit clone git@github.com-work:company/work-project.git\n```\n\n#### Converting Existing Repository\n\n```bash\n# Go to existing repo\ncd ~/projects/my-repo\n\n# Switch to desired profile\ngh-switch use personal\n\n# The remote URL is automatically updated\ngit remote -v\n# origin  git@github.com-personal:johndoe/my-repo.git\n```\n\n#### Auto-Detection\n\n```bash\n# Automatically detect profile from remote URL\ncd ~/projects/some-repo\ngh-switch auto\n# Detects and switches to the appropriate profile\n```\n\n### Advanced Usage\n\n#### Profile Management\n\n```bash\n# Delete a profile\ngh-switch delete old-profile\n\n# Edit profile (delete and re-add)\ngh-switch delete work\ngh-switch add work\n```\n\n#### SSH Key Testing\n\n```bash\n# Test personal account SSH connection\nssh -T git@github.com-personal\n# Hi johndoe! You've successfully authenticated...\n\n# Test work account SSH connection\nssh -T git@github.com-work\n# Hi john-work! You've successfully authenticated...\n```\n\n## 📁 Configuration\n\n### File Locations\n\n```\n~/.config/gh-switch/\n├── config              # Main configuration\n├── current             # Currently active profile\n└── profiles/           # Profile storage\n    ├── personal        # Personal profile config\n    └── work           # Work profile config\n```\n\n### SSH Config Structure\n\ngh-switch adds entries to `~/.ssh/config`:\n\n```ssh\n# GitHub account: personal\nHost github.com-personal\n  HostName github.com\n  User git\n  IdentityFile ~/.ssh/id_ed25519_personal\n  IdentitiesOnly yes\n\n# GitHub account: work\nHost github.com-work\n  HostName github.com\n  User git\n  IdentityFile ~/.ssh/id_ed25519_work\n  IdentitiesOnly yes\n```\n\n### Profile Structure\n\nEach profile stores:\n- SSH key path\n- Git user name\n- Git email address\n- GitHub username\n- SSH host alias\n\n## 🎨 Command Reference\n\n| Command | Description | Example |\n|---------|-------------|---------|\n| `init` | Initialize gh-switch | `gh-switch init` |\n| `add` | Add a new profile | `gh-switch add personal` |\n| `use` | Switch to a profile | `gh-switch use work` |\n| `current` | Show active profile | `gh-switch current` |\n| `list` | List all profiles | `gh-switch list` |\n| `delete` | Remove a profile | `gh-switch delete old` |\n| `auto` | Auto-detect profile | `gh-switch auto` |\n| `help` | Show help message | `gh-switch help` |\n\n### Command Options\n\n- `--global` - Apply profile globally (with `use` command)\n- `--version` / `-v` - Show version information\n\n## 🔧 Shell Aliases\n\nAdd to your `~/.bashrc` or `~/.zshrc` for quicker access:\n\n```bash\n# Quick aliases\nalias ghs='gh-switch'\nalias ghsp='gh-switch use personal'\nalias ghsw='gh-switch use work'\nalias ghsl='gh-switch list'\nalias ghsc='gh-switch current'\n\n# Function to clone with profile\nghclone() {\n  local profile=$1\n  local repo=$2\n  gh-switch use $profile\n  git clone $repo\n}\n\n# Usage: ghclone personal git@github.com-personal:user/repo.git\n```\n\n## 📋 Prerequisites\n\n- **Git**: Version 2.0 or higher\n- **OpenSSH**: Standard SSH client\n- **Bash**: Version 4.0+ (macOS/Linux)\n- **GitHub Account**: With SSH keys configured\n\n### Setting Up SSH Keys\n\nBefore using gh-switch, ensure you have SSH keys for each GitHub account:\n\n```bash\n# Generate key for personal account\nssh-keygen -t ed25519 -f ~/.ssh/id_ed25519_personal -C \"personal@email.com\"\n\n# Generate key for work account\nssh-keygen -t ed25519 -f ~/.ssh/id_ed25519_work -C \"work@company.com\"\n\n# Add keys to SSH agent\nssh-add ~/.ssh/id_ed25519_personal\nssh-add ~/.ssh/id_ed25519_work\n```\n\nThen add each public key to the corresponding GitHub account's settings.\n\n## 🧪 Typical Workflows\n\n### Daily Development\n\n```bash\n# Morning - work on company project\ncd ~/work/company-api\ngh-switch use work\ngit pull origin main\n# ... do work, commits use work identity\n\n# Afternoon - personal project\ncd ~/personal/side-project\ngh-switch use personal\ngit pull origin main\n# ... commits use personal identity\n\n# Check active profile anytime\ngh-switch current\n```\n\n### New Project Setup\n\n```bash\n# Personal project\ngh-switch use personal\nmkdir ~/projects/new-app\ncd ~/projects/new-app\ngit init\ngit remote add origin git@github.com-personal:johndoe/new-app.git\n\n# Work project\ngh-switch use work\nmkdir ~/work/new-service\ncd ~/work/new-service\ngit init\ngit remote add origin git@github.com-work:company/new-service.git\n```\n\n### Migrating Existing Repositories\n\n```bash\n# List current remotes\ncd ~/projects/existing-repo\ngit remote -v\n# origin git@github.com:johndoe/existing-repo.git\n\n# Switch to profile\ngh-switch use personal\n\n# Remote is automatically updated\ngit remote -v\n# origin git@github.com-personal:johndoe/existing-repo.git\n```\n\n## 🐛 Troubleshooting\n\n### Common Issues\n\n**Issue: \"command not found\"**\n```bash\n# Check installation\nwhich gh-switch\n\n# Ensure /usr/local/bin is in PATH\necho $PATH\n\n# Reinstall if needed\nsudo cp bin/gh-switch-standalone /usr/local/bin/gh-switch\n```\n\n**Issue: \"Permission denied (publickey)\"**\n```bash\n# Check SSH key is loaded\nssh-add -l\n\n# Add key to agent\nssh-add ~/.ssh/your_key\n\n# Test connection\nssh -T git@github.com-personal\n```\n\n**Issue: \"Not in a git repository\"**\n```bash\n# For local repository changes\ncd your-git-repo\ngh-switch use profile-name\n\n# For global changes\ngh-switch use profile-name --global\n```\n\n**Issue: SSH config already has entries**\n```bash\n# Backup is created automatically\nls ~/.ssh/config.gh-switch.backup\n\n# Manually restore if needed\ncp ~/.ssh/config.gh-switch.backup ~/.ssh/config\n```\n\n### Debug Commands\n\n```bash\n# Check profile details\ncat ~/.config/gh-switch/profiles/personal\n\n# View current profile\ncat ~/.config/gh-switch/current\n\n# Check SSH config entries\ngrep \"github.com-\" ~/.ssh/config\n\n# Test SSH authentication\nssh -vT git@github.com-personal  # Verbose output\n```\n\n## 🤝 Contributing\n\nWe follow a small PR philosophy - each PR should be 40-80 lines max:\n\n1. Fork the repository\n2. Create your feature branch (`git checkout -b feat/amazing-feature`)\n3. Keep changes focused and minimal\n4. Test thoroughly on macOS and Linux\n5. Submit a Pull Request\n\nSee [CONTRIBUTING.md](CONTRIBUTING.md) for detailed guidelines.\n\n## 📄 Project Structure\n\n```\ngh-switch/\n├── bin/\n│   ├── gh-switch              # Main script (development)\n│   └── gh-switch-standalone   # Standalone version\n├── lib/\n│   ├── common.sh              # Common utilities\n│   ├── profile.sh             # Profile management\n│   ├── ssh_parser.sh          # SSH config parsing\n│   ├── ssh_writer.sh          # SSH config writing\n│   ├── git_config.sh          # Git configuration\n│   └── cmd_*.sh               # Command implementations\n├── completions/\n│   ├── gh-switch.bash         # Bash completion\n│   └── gh-switch.zsh          # Zsh completion\n├── tests/\n│   └── test_basic.sh          # Test suite\n├── install.sh                 # Installation script\n├── Makefile                   # Make targets\n└── README.md                  # This file\n```\n\n## 🚀 Uninstallation\n\n```bash\n# Remove the binary\nsudo rm /usr/local/bin/gh-switch\n\n# Remove configuration (optional - preserves profiles)\nrm -rf ~/.config/gh-switch\n\n# Remove SSH config entries (manual review recommended)\n# Edit ~/.ssh/config and remove gh-switch sections\n```\n\n## 📄 License\n\nMIT License - see [LICENSE](LICENSE) file for details.\n\n## 🙏 Acknowledgments\n\nBuilt with pure shell scripting for maximum compatibility and zero dependencies.\n\n## 📞 Support\n\n- **Issues**: [GitHub Issues](https://github.com/TheDevOpsBlueprint/gh-switch/issues)\n- **Discussions**: [GitHub Discussions](https://github.com/TheDevOpsBlueprint/gh-switch/discussions)\n- **Author**: Valentin Todorov\n\n---\n\n**Note**: This tool modifies your SSH config and Git settings. Always review changes and maintain backups of important configurations.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthedevopsblueprint%2Fgithub-account-switch-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthedevopsblueprint%2Fgithub-account-switch-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthedevopsblueprint%2Fgithub-account-switch-cli/lists"}