Sublime Forum

How do I add a second user?

#1

I’ve been using my standard Github account for all repos, but recently a client required us to use a new username for security reasons. Now I can’t clone the new repo because SM has been configured to use my personal account. I’ve been scouring all menu panels for a “switch user” option, but I cannot find it. I’ve seen some realy complicated script options in this forum, like this one but it looks too advanced for my case. I’m looking for a simple “switch user” option like with Sourcetree, Github desktop, or GitKraken without requiring SSH keys. How can I easily switch the user in Sublime Merge?

0 Likes

#2

Hi @marquizzo,

Thanks for sharing your feedback with the Sublime Merge team.
Could you confirm which platform you are on?

Kind regards,
- Dylan

0 Likes

#3

I’m using Windows10.

0 Likes

#4

Hi @marquizzo,

While we don’t have a dedicated “Switch User” feature, there should be a way to achieve your goals depending on which method of authentication you are using.

Assuming you’re using HTTPS authentication (not SSH), you can edit the git config file of the repository failing to authenticate.

For example, say your GitHub repository is called my_repository, follow the below steps:

  1. Navigate to the local my_repository repository in explorer
  2. Locate the .git folder within the repository
  3. Open the config file located in this folder in your favorite text editor
  4. Locate the remote section of the repository (likely [remote "origin"])
  5. Under the remote section, locate the repository url of the format https://github.com/repository_owner/my_repository.git
  6. Replace this with https://new_username@github.com/repository_owner/my_repository.git (where new_username is the new GitHub username you are required to authenticate with)
  7. Save the file

After all these steps have been completed, the next time perform a pull / push you should see an authentication dialog appear where you can enter the new authentication information.

If you ever want to switch back to the previous account, you can repeat the above, switching steps 5 and 6.

Let me know if this works.

Kind regards,
- Dylan

0 Likes

#5

Thanks Dylan! But how can I have a local my_repository folder with a .git folder if I can’t perform that initial clone repo command?

clone

0 Likes

#6

Hi @marquizzo,

Thanks for your response - could you try replacing the clone URL with the format indicated in step 6 above.

i.e. change https://github.com/repository_owner/my_repository.git to https://new_username@github.com/repository_owner/my_repository.git

If this does not work, I can investigate further.

Kind regards,
- Dylan

0 Likes

#7

Right, I see what you’re saying, but I can’t make it to step 2. There is no .git folder because I can’t even clone the repo. The only account that can clone it is the new username, but my git settings are still configured to use the old username, so it won’t even let me perform the initial clone when I hit the green “Clone” button. So the .git folder and config file does not exist yet.

0 Likes

#8

Hi @marquizzo,

Don’t worry about the previous steps - try the following:

  1. Open Sublime Merge and navigate to the clone page

  2. In the section labeled Source URL, paste the URL as shown in the above screenshot you shared.

  3. After the https:// in the Source URL, add new_username@ where new_username is your new GitHub username.
    For example, say your new GitHub username is marquizzo_new, you would update the url from https://github.com/repository_owner/my_repository.git
    to
    https://marquizzo_new@github.com/repository_owner/my_repository.git

  4. Click the clone button

Once you’ve performed these steps, an authentication dialog should appear prompting you to log in with your new GitHub credentials.

Kind regards,
- Dylan

1 Like

#9

Excellent, thank you! That worked.

1 Like

#10

Great to hear!

It’s worth noting that every time you clone a new repository that requires the new account, you’ll have to perform the above steps (as you’re overriding the default authentication information for GitHub that Windows has cached).

If you’d like to change the default account used to authenticate with GitHub, you’d need to clear the cached credential information.

To clear the cached credential information, you would:

  1. Open Windows Credential Manager (Search for Credential Manager via the start menu)
  2. Select Windows Credentials
  3. Delete the credential entry associated with https://github.com

Then the next time you go to clone a generic github URL (without the username@ portion), you will be prompted to provide updated authentication credentials.

1 Like

#11

I fail to see how using a different user name is more secure. Or what reasons there could be to warrant this.

0 Likes

#12

Yes, but but that’s irrelevant. The reasons behind it is not the point of my question.

1 Like