Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SourceTree multiple github account

I have two different github accounts and two repositories. When cloning the repositories I have used the correct username.

But When I want to commit I am not able to choose between the users. It picks up the global git user by default.

Is there a option to choose which credential to use at the point of the commit in SourceTree.

like image 315
karuthan Avatar asked Jan 08 '15 12:01

karuthan


People also ask

Can you have 2 GitHub accounts?

For most developers, there may be a need to run multiple GitHub accounts on one computer. For instance, you can run an Organization's GitHub account and another one for your personal projects all on the same computer. In this article, you will learn how to use multiple SSH keys for different GitHub accounts.


1 Answers

This worked for me on macOS (... only)

Go to Repository > Repository Settings > Remotes and edit the repository path by adding the user name (like https://<user name>@github.com, by exemple https://[email protected]/landron/Problems.gitinstead of just https://github.com/landron/Problems.git). Then, at the first push (tentative), SourceTree will ask for password (and store it to Keychain if you're on macOS). I found the idea on the Atlassian support site.

Windows update I did not succeed in doing the same because I did not convince SourceTree to make/use two accounts in Credentials Manager: git:https://<user1>@github.com and git:https://<user2>@github.com (they can be created manually by "Add a generic credential" in Control Panel\User Accounts\Credential Manager).

Identification update @Simeon Visser's answer matters (at least) for github statistics (contributions) because github identifies the user by email address (see "The email address used for the commits is associated with your GitHub account." here).

like image 151
Liviu Avatar answered Oct 04 '22 13:10

Liviu