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?
How do I add a second user?
Hi @marquizzo,
Thanks for sharing your feedback with the Sublime Merge team.
Could you confirm which platform you are on?
Kind regards,
- Dylan
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:
- Navigate to the local
my_repository
repository in explorer - Locate the
.git
folder within the repository - Open the
config
file located in this folder in your favorite text editor - Locate the
remote
section of the repository (likely[remote "origin"]
) - Under the remote section, locate the repository url of the format
https://github.com/repository_owner/my_repository.git
- Replace this with
https://new_username@github.com/repository_owner/my_repository.git
(wherenew_username
is the new GitHub username you are required to authenticate with) - 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
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?
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
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.
Hi @marquizzo,
Don’t worry about the previous steps - try the following:
-
Open Sublime Merge and navigate to the clone page
-
In the section labeled Source URL, paste the URL as shown in the above screenshot you shared.
-
After the
https://
in the Source URL, addnew_username@
wherenew_username
is your new GitHub username.
For example, say your new GitHub username ismarquizzo_new
, you would update the url fromhttps://github.com/repository_owner/my_repository.git
to
https://marquizzo_new@github.com/repository_owner/my_repository.git
-
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
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:
- Open Windows Credential Manager (Search for
Credential Manager
via the start menu) - Select
Windows Credentials
- 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.
I fail to see how using a different user name is more secure. Or what reasons there could be to warrant this.
Yes, but but that’s irrelevant. The reasons behind it is not the point of my question.
Ah that is where you are making a mistake. Usually this kind of ‘solution’ is based on voodoo thinking.