Incorrect username to push to Git Repo

mikeleung July 4, 2012

Hi, I have incorrectly typed my username while i was doing a pushing to a Git Repo.

I am now staying at the popup 'Password Required' For user xxx on host github.com.

I cannot provide the correct credential as the username is incorrect. But I can find nowhere to change this saved username.

I am stuck... may be it is a numb question as I am new to SourceTree ( and quite new to Git also ). Can anyone give me any hints?

8 answers

1 accepted

18 votes
Answer accepted
mikeleung October 9, 2012

After several attempts over time, I managed to solve it accidentally. Not sure if it is after some updates or settings.

I would suggest anyone who has the similar problem to take a look for preference -> Network and see if the usernames there would give you some help.

Ivan Brewis May 14, 2014

Had this issue.

What worked for me was Tools->Options->Authentication. SourceTree seems to use this and not the username specified on the actual remore...

This comment lead me to the answer.

Mike Taylor October 7, 2016

Old thread but this worked for me too.  I kept thinking it was a problem with the password because of the fact that SourceTree also won't accept the passphrase for my Putty default_rsa.ppk private key.  I verified I'm entering the right one by using PuttyGen to load it and finally gave up and removed the passphrase with PuttyGen.  But the problem with the repo login was not the password it was that it was using the wrong username (my email address).  So fixed that as noted here under Tools->Options->Authentication.  Didn't work when I tried to change it under Repository Settings.  It will never remember the username I put there.  Like it just ignores it and even opening the dialog again just shows a blank username again.

9 votes
Paul George November 2, 2017

I could authenticate in SourceTree > Tools > Options > Authentication

When pushing, I got a greyed-out and incorrect username prompting for password.

 

Turns out this username was stored in this file:

%localappdata%\Atlassian\SourceTree\userhosts

i.e. C:\Users\Paul\AppData\Local\Atlassian\SourceTree\userhosts

Just delete or edit that file.


Contained something like:

"github.com

[incorrect-email-address]"




rswamy December 12, 2017

This worked for me! Thanks!

호옹잉잉 January 23, 2018

very very Thanks!!!!! you're my god... angel!! 

Nathan Flier February 24, 2018

Thank you so much! :)

gwidaz February 25, 2018

Registered just to up-vote your comment. Finally this solved that nonsense 

Spoon Seah August 12, 2018

Wow you saved my life! I have 2 accounts which I push to 2 different GIT services and this lil userhosts file was causing me so much pain. Thank you!

2 votes
preetam jadakar January 7, 2018

Currently I couldn't find  Preferences->Network at least for MAC version.

Resolved issue by reaching at Preferences -> Advanced.

1 vote
Ivan Brewis May 14, 2014

What worked for me was Tools->Options->Authentication. SourceTree seems to use this and not the username specified on the actual remore...

0 votes
armchairdeity July 4, 2018

So for me, on Mac... I kept getting the wrong login name... here are some key places to look:

  • ~/Library/ApplicationSupport/SourceTree - you'll see your passwords in there stored as one file peer username/domain combo.
  • KeyChain Access - your logins are stored there under labels that look like this:
    • git.foo.com Access Key for {username}

The weird thing was no matter how many times I removed and re-added them it kept asking for just the password and never the username. I even tried adding my username @ my host/domain name... no good.

Finally I figured out that I had added my username as "myId@host.dom" under Preferences... > ADVANCED > Default Usernames and we had since switched to a new login format that drops the @host.dom part off, so I forced myself to log in with the wrong username. Once I removed that entry everything was just fine, I was prompted for my username next time I tried to connect and it was all good.

Screen Shot 2018-07-04 at 5.42.57 PM.png

Tarak Bhavsar June 21, 2021

For me on MacOS BigSur 11.4 and Sourcetree, tried above but didn't fixed the multiple users and sourceTree was not picking up the correct user

 

Alternatively tried updating my .gitconfig file and worked

```

$ vi ~/.gitconfig

========

....

[mergetool "sourcetree"]

        cmd = /Applications/Sourcetree.app/Contents/Resources/opendiff-w.sh \"$LOCAL\" \"$REMOTE\" -ancestor \"$BASE\" -merge \"$MERGED\"

        trustExitCode = true

[user]

        name = <user>                <--- Changed the user

        email = <user_email>     <--- Changed the email

....

=========

```

0 votes
kAli70 April 25, 2017

I had the same problem and I solved it by going to the prefrences->Network and removed the accoount which I do not know its password.....I assume you entered this account accedientally

It worked for me

 

0 votes
Chris Fabri May 16, 2015

I had this same problem - here is what I did; from the sourceTree mac menu, select:

    SourceTree -->Network

There in the dialog was the incorrect login name to gitHub, which I then changed.  Coms to the repo then began to work.

0 votes
Colin Goudie
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 4, 2012

Go to the folder where you git repo is checked out and edit .git/config

You will find the repository URL in there and it probably has your incorrect username set infront of it. Something like username@github.com

Change it there and push again

mikeleung July 4, 2012

Thanks Colin for your answer. No luck, my config file looks like this:

repositoryformatversion = 0

3 filemode = false

4 bare = false

5 logallrefupdates = true

6 ignorecase = true

7 [remote "origin"]

8 fetch = +refs/heads/*:refs/remotes/origin/*

9 url = https://github.com/xxxxxx

10 [branch "master"]

11 remote = origin

12 merge = refs/heads/master

13 [branch "server-edition"]

14 remote = origin

15 merge = refs/heads/server-edition

16 [user]

Nothing looks like as mentioned...
Colin Goudie
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 4, 2012

Maybe check your global git config see if anything is in there. Not sure where sourcetree might store that username.

It's generally in your home dir. ~/.gitconfig

stevestreeting
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 4, 2012

Hmm, the username field should only be disabled if it's present in the URL. What happens if you submit the login box anyway? It should definitely prompt you again to supply a username if the login fails once.

mikeleung July 5, 2012

Hi Steve. The username field is not disabled actually. I recall it appeared the first time I try to do the 'push'.

However I realized that I got a typo in username which makes it not working. But it seems there is no place for me correct / remove the saved username....

stevestreeting
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 5, 2012

Oh I see, in that case if you overtype the username and the login succeeds, it should have saved that username as the new default to use.

One way to guarantee fixing this is to be unambiguous in the URL you use for the remote. So for example instead of using https://domain.com/my/repo, if you use https://username@domain.com/my/repo instead then the username is guaranteed to be correct. You can change this by clicking 'Settings' in the repository window toolbar (top-right) and editing the remote URL.

If the user is not present in the URL, SourceTree uses a default which *should* be based on whatever the last successful login was. If after you overtype the username and login successfully it comes back with the previous default next time, that's a bug but I'm not sure how it can happen right now.

mikeleung July 10, 2012

Hi Steve,

I tried to change it to https://username@domain....

It is using my specified 'username' right now.

However, the next time I come back. The default username remains unchanged... I may need to change the url manually everytime I push updates.

Seems a workaround at the moment though. Thanks

stevestreeting
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 10, 2012

Did you change it in the remote URL, under "Settings" in the repository window? This is permanent, rather than selecting 'Custom' in the Push dialog and changing the URL there, which is only temporary.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events