Thanks to visit codestin.com
Credit goes to github.com

Skip to content

This script helps with users who have multiple GitHub profiles and require to switch between them on a regular basis.

Notifications You must be signed in to change notification settings

to-ie/gitswitch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 

Repository files navigation

Gitswitch

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.


Why

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.


Features

  • 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.)


Requirements

  • 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 gh installed or a PAT yet, follow GitHub’s docs to set them up.


Quick start

# 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:
gitswitch

The 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.


Usage

After setup, run:

gitswitch

You’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-origin to inspect the resulting configuration if you’re curious.


Updating

If you pull a newer version of the script, simply run the installer again:

bash /path/to/gitswitch/switch.sh

It will reuse your saved information where possible and prompt when changes are needed.


Troubleshooting

  • "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.name and git config user.email to 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.

Roadmap / ideas

  • 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.


License

Copyright © toie. If you intend to publish binaries or redistribute, please add a LICENSE file to this repository.


Acknowledgements

Inspired by common workflows for multi‑account Git usage and tools in this space.

About

This script helps with users who have multiple GitHub profiles and require to switch between them on a regular basis.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages