Search code examples
atlassian-sourcetree

Sourcetree pushing with the wrong user?


Background:

  • I have two GitHub accounts: a main account and a rarely-used account.
  • If I remember correctly, I have used both of them with the copy of Sourcetree on my laptop.
  • I currently have just my main GitHub account listed in my Sourcetree's Tools-->Options-->Authentication settings page.

Problem:

  • When I try to push a branch from my laptop to my GitHub remote for my main account, it fails, with the git error message indicating that I had actually tried to push with my rarely-used account, even though it's nowhere to be found in my Sourcetree settings pages.

Solution

  • The Atlassian team provided a solution for this (here):

    • Open the repo
    • Click "Settings"
    • Double click on the "origin" item in the listing
    • Edit the url to add your username before the URL of the repo. Here are some examples: https://USERNAME@contoso.com/repo/blah.git
      https://USERNAME@github.com/host/repo_name
    • You should be prompted for a password the next time you try to push or pull