Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jordiup/1963fb97ac816943d1553dad38e87ced to your computer and use it in GitHub Desktop.
Save jordiup/1963fb97ac816943d1553dad38e87ced to your computer and use it in GitHub Desktop.
How to use multiple GitHub accounts in GitHub Desktop

How to use multiple GitHub accounts in GitHub Desktop

Background

Let's say you have two users and repos likejordiup/repo1 and not_jordiup/repo2.

You want to push and pull from them using different accounts.

Solution

  1. Clone both the repos to your local (can use this approach)

  2. Now add these repos to GitHub Desktop via File --> Add Local Repository

  3. Create access tokens for both the accounts. The easiest way to do this is with gh cli:

# account one
gh auth login
# then again for account two
gh auth login
# now generate the token
gh auth token
# returns gho_aj0989asf*************

# switch account 
gh auth switch
  1. Update the value of the remote. Go to repo1 in GH Desktop, Repository --> Repository Settings and change Remote to https:<gtoken1>@github.com/not_jordiup/repo2 and save.

  2. Now you can push and pull. (Do the same for any repos you wish to access from the other account)!

image

Caveats:

  • You still have to commit using correct email etc which you can do via repo-specific git configuration.
  • You cannot open pull requests using the shortcut keys

P.S. if you found this helpful, make sure to ⭐

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment