GitHub Desktop Multi-account switcher
desktop/desktop#3707 Since GitHub Desktop doesn't natively support multiple accounts.
So users often have to log out and log back into their work and personnel accounts and re-add the repos they're working on.
This aims to solve that problem by keeping a copy Roaming\Github Desktop
for each user and then renaming the folder when asked and rename the folder back when switching to a new user. (records kept track using ~/gitswitch.json
file)
- Make user login with each account in setup (
init
) process. - rename
.gitconfig
andGitHub Desktop
folder with username at the end. - When the
switch
method is called rename the user folder toGitHub Desktop
and copy over the.gitconfuser
file to.gitconf
. - update the
~/gitswitch.json
with the current user details.
- Q: Does this work on Linux / macOS ?
Answer
No, this script only supports windows for now. Feel free to open a pull request if you have a patch for Linux / macOS- Q: How do you use this?
Answer
Check the installation section below.- With Python >= 3.6
pip install pyGitSwitch
or install the latest development branch using
pip install git+https://github.com/AnvithLobo/pygitswitch
- Windows Standalone exe
Download the exe from releases (TBD) and add the exe and add the containing folder to your PATH
https://stackoverflow.com/questions/44272416/how-to-add-a-folder-to-path-environment-variable-in-windows-10
- Run
gitswitch init
(First run only)
$ gitswitch init --help
usage: gitswitch init [-h] [-c USERNAME] [-u USERNAME [USERNAME ...]]
options:
-h, --help show this help message and exit
-c USERNAME, --current-user USERNAME
Store current user login as (do not delete current user)
-u USERNAME [USERNAME ...], --users USERNAME [USERNAME ...]
all usernames separated by space
$ gitswitch init -c user1 -u user2 user3
$ gitswitch init -u user1 user2
- Run account switcher
$ gitswitch switch --help
gitswitch switch [-h] [-u USERNAME] [-d]
options:
-h, --help show this help message and exit
-u USERNAME, --user USERNAME
username / userid to switch to
-d, --do-not-start-github
Do NOT Start github after switching account
$ gitswitch
Stopping Github Process...
Select Account (Current User: User1)
----------------------------------------
1. User1
2. User2
3. User3
Enter Your Choice (1-3) : 3
---------------
Switching account to user : User3
Done
just running gitswitch
without any arguments will trigger the switch
command by default
- Non-interactive mode
$ gitswitch switch -u User2
Switching account to user : User2
Done
$ gitswitch switch -u 1
Stopping Github Process...
Switching account to user : User1
Done
- Add more users.
$ gitswitch adduser -h
usage: gitswitch adduser [-h] USERNAME [USERNAME ...]
positional arguments:
USERNAME
options:
-h, --help show this help message and exit
$ gitswitch adduser user4 user5
$ gitswitch adduser user6
- Delete user/s.
$ gitswitch deluser -h
usage: gitswitch deluser [-h] USERNAME [USERNAME ...]
positional arguments:
USERNAME
options:
-h, --help show this help message and exit
$ gitswitch deluser user2 user5
$ gitswitch deluser user1
- List user/s.
$ gitswitch showusers
----------------------------------
| ID | User Name | Current User |
----------------------------------
| 1 | User1 | ✓️ |
| 2 | User2 | X |
| 3 | User3 | X |
----------------------------------
- ...