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

GitGithub

Git Problem Overview


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

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

Is there only re clone the repository?

Git Solutions


Solution 1 - Git

If you had your remote's password changed only, not the username, then try the following command to check remote's info:-

> git remote show origin

This will ask for your password for the given git user, fill that in correctly, and now try:-

> git pull

or,

> git push

It should work unless you have to change other things like username or remote URL, you can take a look at the following Git documentation:-

> https://help.github.com/articles/setting-your-username-in-git/ > > https://help.github.com/articles/changing-a-remote-s-url/

Solution 2 - Git

To update the password in your Terminal. Try the below command, It will prompt you password again.

git push -u origin master

Solution 3 - Git

The OP kenu.heo has worked around the issue by removing, then re-cloning the repo.

But for other:

It depends on your OS, git version and protocol you are using.

Depending on the OS, you have ways to cache your credentials (OSX KeyChain on Mac, netrc credential helper on Windows or Linux), and that could explain why your push isn't working after changing your GitHub password.
For a keychain, you would need to reset that password stored in it.

That password issue also suggest that you are using an https url (not an ssh one, which would depends on public/private ssh keys, and wouldn't be influenced by a GitHub account password, since the public SSH key registered to your GitHub account wouldn't have changed).

Check that with a git remote -v.

You can force git to use your GitHub login with a:

git remote set-url origin https://[email protected]/Username/MyRepo.git

(replace 'Username' and 'MyRepo.git' by your own values)

Then try again to push, it should ask for your GitHub password. Enter the new one.

If this doesn't work, check if you have activated the 2FA (2-Form Authentication). If that is the case, you need to generate a PTA (Personal Token Access).
See more at "Configure Git clients, like GitHub for Windows, to not ask for authentication".

Solution 4 - Git

On a Windows System none of the steps worked for me, the problem is that the credentials are stored in Windows Credentials Manager.

You can go to Control Panel -> User Accounts -> Credential Manager -> Windows Credentials

Under Generic Credentials you will find your git Url, expand the selection and click on edit.

Once edited just trigger a git push again and it should work.

Source of information :- https://stackoverflow.com/questions/15381198/remove-credentials-from-git

Solution 5 - Git

From what I've experienced, you just need to re-enter the remote-addr.

And git will ask usr/password for the new one rather than keeping silent and use the deprecated one.

see your remotes, locate which one you want to change

>git remote  
github
gitcafe
company

for example, if you changed your company repo password, you can do:

>git remote remove company

This won't touch your folder, won't touch your commits. This just delete a url-string from git

Then, add this url again:

>git remote add company https://git.AyCramba.com/xxx.git

Push to it:

>git push company master
username for 'https://git.AyCramba.com':
password for 'https://git.AyCramba.com':

Then it starts pushing

Hope it helps.

Solution 6 - Git

The username and password may be stored in Windows Credential Manger. Check and update there, if necessary.

(I know that's a bit obvious and simple, but might help some people.)

Solution 7 - Git

You can update the Username and password by this command:

$ git remote set-url origin https://<USERNAME>:<PASSWORD>@github.com/path/to/repo.git

make sure to change USERNAME to your git username and PASSWORD to your new git password.

Next git push should work for you.

Learn more about it in this article

Solution 8 - Git

For me, running git on Windows7 using git-bash, running:

git push origin master

Got it working. That prompted Windows7 to ask again for my git creds, and then stored them (whereever Windows does), to update the password.

Solution 9 - Git

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://[email protected]/CompanyName/RepoName.git

Then

git remote show origin

prompted with

Password for 'https://[email protected]': 

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

Solution 10 - Git

If you have setup Github 2FA Auth, you need a personal access token (in place of your github password in git cli), follow this instructions to create it: https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line

Then do something like > git checkout master > > git pull origin <--- At this point you'll be asked for your credentials, enter your normal github user and as password paste the token generated in the link above.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionkenu.heoView Question on Stackoverflow
Solution 1 - GitAmitView Answer on Stackoverflow
Solution 2 - GithiddenpearlsView Answer on Stackoverflow
Solution 3 - GitVonCView Answer on Stackoverflow
Solution 4 - GitSapView Answer on Stackoverflow
Solution 5 - GitChironView Answer on Stackoverflow
Solution 6 - GitsquiccView Answer on Stackoverflow
Solution 7 - GitGideon BabuView Answer on Stackoverflow
Solution 8 - GitEric ManleyView Answer on Stackoverflow
Solution 9 - GitChalkBoardView Answer on Stackoverflow
Solution 10 - GitFernando Gonzalez SanchezView Answer on Stackoverflow