Changed GitHub password, no longer able to push back to the remote

后端 未结 10 1994
日久生厌
日久生厌 2020-12-07 08:28

After I changed my GitHub password, I am unable to push to the remote:

$ git push origin master
remote: Invalid username or password.

Is th

10条回答
  •  天命终不由人
    2020-12-07 09:19

    Ok, the original post is quite old, but it's the top result in Google and none of the answers worked for me. Several other SO and GH posts didn't work either. Posting this to help anyone following me here!

    My situation is slightly different: Personal GH account, pushing to a private Company repo, using SSH and the git command line on Mac. My password is not stored either in my .gitconfig nor in any keychain nor in git credential.helper.

    In the example below PersonalName is my GH account, CompanyName is the company (the owner of the repo on GH) and RepoName is the repository.

    My original error message was somewhat different also: attempting git push origin master resulted in

    remote: Repository not found.
    fatal: repository 'https://github.com/CompanyName/RepoName.git/' not found
    

    The remote was working before my GH password change, and I didn't want to remove the remote because I had local changes that I needed to push.

    Eventually a reply by seveas to this question on the GitHub Community Forum pointed me in the right direction. The key thing was to link my GH account name with the remote (private) repo.

    This worked for me:

    git remote set-url origin https://PersonalName@github.com/CompanyName/RepoName.git
    

    Then

    git remote show origin
    

    prompted with

    Password for 'https://PersonalName@github.com': 
    

    I was able to enter my new password, see the remote details and git push origin master succeeded.

提交回复
热议问题