A tiny shell script that helps developers who use multiple GitHub profiles (e.g., work + personal) quickly switch identities on a machine.
Works best on Ubuntu and other Linux distributions.
Switching between Git identities by hand (editing ~/.gitconfig, juggling tokens/keys, etc.) is fiddly and error‑prone. Gitswitch guides you through a one‑time setup and then lets you switch with a single command.
- Interactive, one‑time setup for each GitHub profile
- Simple command to switch the active profile
- Uses your Git configuration (no daemons or long‑running processes)
(See the script for exact steps performed.)
- Linux (Ubuntu or similar)
- Git installed and on your
PATH - GitHub CLI (
gh) installed - A GitHub Personal Access Token (PAT) for each profile you want to use
If you don’t have
ghinstalled or a PAT yet, follow GitHub’s docs to set them up.
# 1) Clone the repo anywhere (e.g. to a temp directory)
cd /tmp && git clone https://github.com/to-ie/gitswitch
# 2) Run the installer (it’s an interactive script)
bash gitswitch/switch.sh
# 3) Follow the prompts to add each of your profiles
# 4) That’s it. From now on, switch with:
gitswitchThe script will walk you through adding each account (nickname, username, email, PAT) and wiring your Git config accordingly. After installation, you can delete the cloned folder if you like.
After setup, run:
gitswitchYou’ll be presented with your saved profiles and can choose which one to activate. The script updates your Git configuration so new commits use the correct identity.
Tip: run
git config --list --show-originto inspect the resulting configuration if you’re curious.
If you pull a newer version of the script, simply run the installer again:
bash /path/to/gitswitch/switch.shIt will reuse your saved information where possible and prompt when changes are needed.
- "Command not found: gitswitch" – Open a new shell so your profile reloads, or add the installed location to your
PATH. - Wrong name/email in commits – In a repo, run
git config user.nameandgit config user.emailto check overrides. Remove per‑repo overrides if you want to use the global identity. - GitHub authentication issues – Ensure your PAT is valid and has the scopes you need for the actions you perform (e.g., pushing to private repos). Re‑run the installer if you rotated a token.
- Optional SSH‑key setup alongside HTTPS tokens
- Non‑interactive flags for CI/dotfile automation
- macOS support
Contributions are welcome—feel free to open issues or PRs.
Copyright © toie. If you intend to publish binaries or redistribute, please add a LICENSE file to this repository.
Inspired by common workflows for multi‑account Git usage and tools in this space.